-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
Is there a way to keep zk javascript files in the browser cache to optimize bandwidth ?
Hi Alassane,
None of ZK JS files will be re-loaded unless the page is reloaded.
And ZK engine only load required js files at the first rendering, and load others if necessary.
/robbie
Robbie, could you expand on this a bit? I am currently taking a "page based" approach to navigation rather than "single page navigation". Are you saying that each time I go to a new Zk-based page, even one I have been to already, the JS files will be reloaded? Perhaps this is what Luuzz wants to control (I do!). It seems obvious that the JS won't be reloaded if you never leave or reload the page.
/Daryl
Hi Daryl,
If you do it Ajax way, ZK engine won't reload duplicate JS file again. But you use sendredirect, or the user press F5, the page will be reloaded, so does those js files. btw, some browsers would cache js files.
/robbie
Is there any way in Zk to set headers or something so the JS pages are always cached by the browser? I know that if I have my JS files (from other projects) served straight off the file system, they are only downloaded again if they change (or are purged from the cache). But Zk serves the JS from a servlet, so maybe there is something going on that makes the browser think it should download JS each time?
/Daryl
A way to "externalize the static data (/web/..)" is on my todo-list, but it is not so important and no time...
My impressions:
XXXXcss.dsp are not static!
They use tags to include, conditions (browser-engine) - so it could only hosted by a javacontainer.
Another way could be to override the zkau-engine and add cache-settings for all /web/. It's important that only the browser is allowed to ache - not i.e. a proxy!
Change the web.xml:
<servlet> <description>The asynchronous update engine for ZK</description> <servlet-name>auEngine</servlet-name> <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping>
and add:
<servlet-mapping>
<servlet-name>cachedEngine</servlet-name>
<url-pattern>/zkau/web/*</url-pattern>
</servlet-mapping>
<servlet>
<description>The asynchronous update engine for ZK</description>
<servlet-name>cachedEngine</servlet-name>
<servlet-class>your.package.YourDHtmlUpdateServlet</servlet-class>
</servlet>
Another idea is just to externalize the pictures. This style-util can help.
Extract, search/replace the path of the images, create a ext. Style. Configure cache for the external imagedir.
/Robert
Sorry it is only an idea at this time. Actually i've no time to check this it out. I should have more time in july (there i have to do a small page-ortiented project).
Another option is post a feature request like "Allow configure cachesettings for static content (/zkau/web/*)".
In my opinion it should no promblem to set a cache time i.e. 8 hours for the /zkau/web/*content (with disabling proxycaching for customized js-files!)
However, if i found the time, i'll try a quick&dirty solution for some tests.
/Robert
Hi guys,
I've been looking for some caching mechanism and found only this thread. Any success or improvements on this matter?
Best regards,
Madruga
Asked: 2009-01-22 09:47:57 +0800
Seen: 379 times
Last updated: Aug 13 '09