5

In XPages "use runtime optimized javascript and css resources" is a really cool feature because it joins all js files in just a file and all css files in just a css file.

However I noticed that the joined files are not cached (they always return status 200) and when you don't use "use runtime optimized javascript and css resources" they do (and return status 304).

Is good to reduce http requests but is bad always to retrieve from server the js and css files when they could be cached via ETag or Last-Modified http headers. Anybody knows if I'm missing something or if there is way to cache the joined files when you use the feature "use runtime optimized javascript and css resources" (application properties > XPages tab > Performance section > use runtime optimized javascript and css resources).

Naveen
  • 6,786
  • 10
  • 37
  • 85
Johann Echavarria
  • 9,695
  • 4
  • 26
  • 32
  • 2
    I just checked this on a 9.0.1 server and it looks like your statement isn't entirely true: the minified (CSS & JavaScript) resources **are** cached: by default the server adds an `Expires` header that's 10 days in the future. This will cause the browser to (during that time period) not perform a request for those resources at all and serve them from cache immediately. – Mark Leusink Jan 04 '14 at 12:32
  • 1
    Agree. The resources *are* cached. – Per Henrik Lausten Jan 04 '14 at 14:40

2 Answers2

7

The runtime optimized resources are cached.

Here's an example: enter image description here

If you are looking at the network activity and the response codes using Chrome Developer Tools, then make sure that it has not been set to "Disable cache (while DevTools is open)": enter image description here

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • Thank you for your answer. I was hitting f5 as @Panu mentioned. Also I wasn't aware of the difference between the status (200 cache)(also called bfcache) and (304). [http://stackoverflow.com/questions/1665082/http-status-code-200-cache-vs-status-code-304](http://stackoverflow.com/questions/1665082/http-status-code-200-cache-vs-status-code-304) (Ben's answer). Http header expires is cool and we can set it from Domino Designer in application > properties > Basic tab > Custom Browser Cache Expiration. – Johann Echavarria Jan 07 '14 at 15:08
1

Pressing Enter in URL bar will respect the Expires header and get the file from cache. But if you click reload or press F5 then the file will be reloaded. This is the behavior at least in Chrome and Firefox.

The cache works correctly when navigating from page to page.

Panu Haaramo
  • 2,932
  • 19
  • 41
  • 1
    Thank you for your answer. You got it, I was hitting f5 instead enter and the behaviour is what you say when I check previously "use runtime optimized javascript and css resources". What confused me is: when I uncheck "use runtime optimized javascript and css resources" and hit f5, the files (js and css) are cached and return 304 status. Finally I learned the difference beetwen (200 bfcache) and 304 and that's the http headers **expires** and **If-Modified-Since** . See my comment to @Per 's answer. – Johann Echavarria Jan 07 '14 at 15:19