Page 1 of 2

Caching the JavaScript files

Posted: 28 Dec 2010, 19:47
by primehthb
Hi,

my website is very slow to load. I have analyzed the problem with FireBug Firefox extension, and found that the .js files loaded by PrimeFaces are up to 3 seconds to load, individually. Specifically, jquery.js, jquery-ui.js, menu.js, core.js and some accompanying CSS files are the reason for this.

It seems the files are never stored in the browser cache.

I am using

Code: Select all

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>    
    <param-value>Production</param-value>
</context-param>
... so that is not the problem.

I'm using Glassfish 3.0.1 with PrimeFaces 2.2 RC2.

Has anyone else encountered this problem?

Thanks.

Re: Caching the JavaScript files

Posted: 02 Jan 2011, 22:31
by primehthb
Anyone ? It seems the browser always reloads these files. They are never cached.

Re: Caching the JavaScript files

Posted: 03 Jan 2011, 07:31
by MISS_DUKE

Re: Caching the JavaScript files

Posted: 04 Jan 2011, 00:59
by primehthb
Hi and thanks for your response.

I'm having a hard time deriving a concrete solution from these threads.

I'm using Apache with mod_proxy in front of my Glassfish 3. Perhaps I should let it cache these resources instead?

Also, can you post a concrete example of your servlet filter code ?

Thanks.

Re: Caching the JavaScript files

Posted: 04 Jan 2011, 13:04
by cagatay.civici
As JSF 2.0 APIs are loading the resources, this questions is more related to the JSF impl not PrimeFaces library.

Re: Caching the JavaScript files

Posted: 07 Jan 2011, 21:59
by derek
in case someone is looking for an answer to this problem, after upgrading to mojarra-2.0.3 glassfish handled caching all the resources for me.. with mojarra-2.0.2 it did not.


Derek

Re: Caching the JavaScript files

Posted: 07 Jan 2011, 22:39
by primehthb
Hi,

You are correct. I just upgraded, and now everything is cached.

Is there a way to control the caching? Will it result in problems when I change some of the source files?

Thanks.

Re: Caching the JavaScript files

Posted: 08 Jan 2011, 02:48
by MISS_DUKE
I you think Mojarra 2.0.3 automatically handle caching, can you please post the HTTP response headers of a typical static source?

Re: Caching the JavaScript files

Posted: 08 Jan 2011, 12:03
by primehthb
It's just 304 NOT MODIFIED

Re: Caching the JavaScript files

Posted: 08 Jan 2011, 12:18
by MISS_DUKE
304 NOT MODIFIED means your browser in contacting the server (and spending considerable time in establishing the connection) about the modified information, it is not the proper caching anyway.