Project

General

Profile

Actions

Patch #1186

closed

JS should be cached in production mode to save bandwith and cpu

Added by Philippe Lafoucrière about 16 years ago. Updated over 15 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Target version:
-
Start date:
2008-05-06
Due date:
% Done:

100%

Estimated time:

Description

Attached in very small patch to allow caching the JS files in production mode.


Files

add_cache_for_js_in_layout_base.diff (580 Bytes) add_cache_for_js_in_layout_base.diff Patch file to add cache for JS Philippe Lafoucrière, 2008-05-06 15:56

Related issues

Related to Redmine - Defect #1821: failed to set repositoryClosed2008-08-27

Actions
Actions #1

Updated by Eric Davis almost 16 years ago

  • Status changed from New to Resolved
  • Assignee set to Eric Davis
  • % Done changed from 0 to 100

Applied patch in r1748. Javascript files will now be cached as a single file.

Actions #2

Updated by Philippe Lafoucrière almost 16 years ago

Be careful if later you want to use other javascript lib than the ones packaged with rails. I had surprises where some libs are requesting prototype, and they were not able to detect it any more with the cache mode.
To explain the cache mode in one line, all js files are concatened in one single file, easily compressable and cacheable.

Thanks

Actions #3

Updated by Jan Losinski almost 16 years ago

For me this Patch wont work.
If I've applied it there are no actions on the comment buttons of the issues, also the context menu at the issue list will not be available.
If I've removed it all the things works fine.

Actions #4

Updated by Eric Davis almost 16 years ago

Philippe Lafoucrière wrote:

Be careful if later you want to use other javascript lib than the ones packaged with rails. I had surprises where some libs are requesting prototype, and they were not able to detect it any more with the cache mode.

Can you provide an example? I still see the Prototype object:

>>> Prototype.Version
"1.6.0.1" 

Jan Losinski wrote:

For me this Patch wont work.
If I've applied it there are no actions on the comment buttons of the issues, also the context menu at the issue list will not be available.
If I've removed it all the things works fine.

Can you provide me your browser version and Operating system version? The context menu and issue links are working fine for me in Firefox. Also make sure you've cleared the browser cache.

Actions #5

Updated by Philippe Lafoucrière almost 16 years ago

I know starbox (http://www.nickstakenburg.com/projects/starbox/) at least won't work in this case (all js compacted in one all.js file).

Thx
Philippe

Actions #6

Updated by Jan Losinski almost 16 years ago

Eric Davis wrote:

Can you provide me your browser version and Operating system version? The context menu and issue links are working fine for me in Firefox. Also make sure you've cleared the browser cache.

The cache was cleared, the Problem exist until I remove :cache => true
Browser: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Rails: 2.1.0
Ruby: 1.8.2
libjs-prototype: 1.6.0.2

Rails runs in a apache-fcgid environment.

Actions #7

Updated by Eric Davis almost 16 years ago

Jan Losinski wrote:

The cache was cleared, the Problem exist until I remove :cache => true
Browser: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Rails: 2.1.0
Ruby: 1.8.2
libjs-prototype: 1.6.0.2

Rails runs in a apache-fcgid environment.

I tested with the exact same browser and the context menu is working for me. In fact the context menu isn't included in the cached JavaScript so it shouldn't be affected at all.

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)

Actions #8

Updated by Ralph Lange almost 16 years ago

I'm having the same problem: upgrading from r1747 to r1748 breaks a bunch of things in my installation:
  • Wiki formatting buttons disappear (for project descriptions, issues, comments...)
  • The preview link does not work (when creating or commenting an issue)
  • Issue filtering does no work: parts of filter expressions are missing, adding filters does not work, listing all issues (including closed) does not work, ...

I tried migrating the db, clearing the redmine cache and clearing the browser cache with no result.

Removing ":cache => true" puts everything back to normal.

Rails 2.1.0, ruby 1.8.5
Browser: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1

Actions #9

Updated by Jean-Philippe Lang almost 16 years ago

I think the problem is due to the fact that your application can't write all.js in /public/javascripts folder because the app doesn't have write access on this repository. And thus, all javascripts are unavailable.

I personnally use this cache technique for a while here on redmine.org but everyone may not want to give write access to the app on the /public folder. So IMHO, this patch should be reverted.

Actions #10

Updated by Jan Losinski almost 16 years ago

Jean-Philippe Lang wrote:

I think the problem is due to the fact that your application can't write all.js in /public folder because the app doesn't have write access on this repository.

On my Box, all.js exist in /public/javascripts and RoR can write to it, but it's an empty file.

Actions #11

Updated by Philippe Lafoucrière almost 16 years ago

Ok, seeing all the problems this patch is raising, and the very little improvement, we can clearly reject the patch. Sorry for that guys.

Actions #12

Updated by Eric Davis almost 16 years ago

  • Target version deleted (0.8)

Jean-Philippe Lang wrote:

I think the problem is due to the fact that your application can't write all.js in /public/javascripts folder because the app doesn't have write access on this repository. And thus, all javascripts are unavailable.

Ah, didn't even think about that since my Redmine runs as the user who owns the files. So it was able to write to public.

Philippe Lafoucrière wrote:

Ok, seeing all the problems this patch is raising, and the very little improvement, we can clearly reject the patch. Sorry for that guys.

Don't worry about it, that's what trunk is for, trying out new features. I tested it myself and it worked great in my environment so I committing the patch.

I've reverted the commit. Can everyone who had an issue please update to r1771 and see if the problem is reverted. Sorry for the hassle.

Actions #13

Updated by Paul Rivier almost 16 years ago

Eric Davis wrote:

I've reverted the commit. Can everyone who had an issue please update to r1771 and see if the problem is reverted. Sorry for the hassle.

If the problem may occur on some installations, and is server side configuration issue, it does not make the feature proposed unusable for everybody. Can't it just be let as an option for site administrator ?

Actions #14

Updated by Richard Hurt almost 16 years ago

It looks like r1786 turned this back on somehow and my installation is broken. Can we get this turned back off please or is there some other fix in place that allows it to be toggled on/off?

Actions #15

Updated by Norbert Wenzel almost 16 years ago

Has this been turned on again in rev1794? I was just wondering what those bugs were, which occured every now and then, and disappeared after reloading. I had to change the folder permissions for "javascripts" and now Redmine is working with JS support again.

Actions #16

Updated by Eric Davis almost 16 years ago

Richard Hurt wrote:

It looks like r1786 turned this back on somehow and my installation is broken. Can we get this turned back off please or is there some other fix in place that allows it to be toggled on/off?

The merge from the hooks branch in r1786 pulled in the bug. If you update to r1795, I've backed it out.

Actions #17

Updated by Richard Hurt over 15 years ago

Eric Davis wrote:

Richard Hurt wrote:

It looks like r1786 turned this back on somehow and my installation is broken. Can we get this turned back off please or is there some other fix in place that allows it to be toggled on/off?

The merge from the hooks branch in r1786 pulled in the bug. If you update to r1795, I've backed it out.

Thanks, that did the trick.

Later...
Richard

Actions #18

Updated by Eric Davis over 15 years ago

  • Status changed from Resolved to Closed
  • Assignee deleted (Eric Davis)

Closing, we can revisit caching later as part of a more comprehensive optimization strategy.

Actions

Also available in: Atom PDF