0

ZK Caching

asked 2009-01-22 09:47:57 +0800

Luuzz gravatar image Luuzz
109 1

Hello,
Is there a way to keep zk javascript files in the browser cache to optimize bandwidth ?

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2009-02-02 08:56:02 +0800

robbiecheng gravatar image robbiecheng
1144 2
http://robbiecheng.sys-co...

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

link publish delete flag offensive edit

answered 2009-02-10 15:19:35 +0800

dastultz gravatar image dastultz
797 9

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

link publish delete flag offensive edit

answered 2009-02-12 07:23:12 +0800

robbiecheng gravatar image robbiecheng
1144 2
http://robbiecheng.sys-co...

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

link publish delete flag offensive edit

answered 2009-03-16 14:08:07 +0800

dastultz gravatar image dastultz
797 9

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

link publish delete flag offensive edit

answered 2009-03-16 22:22:53 +0800

robertpic71 gravatar image robertpic71
1275 1

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

link publish delete flag offensive edit

answered 2009-06-04 10:40:14 +0800

Luuzz gravatar image Luuzz
109 1

Hello,
this solution seems interesting, can you please submit an example for this servlet ?
Best regards,
Alassane.

link publish delete flag offensive edit

answered 2009-06-04 12:37:43 +0800

robertpic71 gravatar image robertpic71
1275 1

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

link publish delete flag offensive edit

answered 2009-06-04 12:50:58 +0800

Luuzz gravatar image Luuzz
109 1

OK.
Do you mean that i can test caching the /zkau/web/* resources with expires_mod apache module ?

link publish delete flag offensive edit

answered 2009-08-13 13:10:21 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-01-22 09:47:57 +0800

Seen: 379 times

Last updated: Aug 13 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More