-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello all,
I have problems with changing theme of a zul on IE, i have a Menu (.zul) with a theme (theme A) and one Menuitem (anotherwindow.zul) with another theme (theme B), I load the Menu with Theme A and when I open the other zul, Theme B doesn't load well on IE. I had the same issue on Chrome but I solved that with the liberary-property (<library-property> <name>org.zkoss.web.classWebResource.cache</name> <value>false</value> </library-property>) on the zk.xml but doesn't solve the problem on IE.
Seems like the problem is that IE doesn't clear the cache (chrome and mozzilla does it with the library property but not IE) any solution for that?
Thanks.
Hi Softteam,
The library property will prevent the web server from caching the result of wpd files compilation. As far as I know, it doesn't affect the client.
However, even if a new wpd file is generated, it will have no effect if the client still caches the old version. You can verify that this is the case by forcing a refresh in IE (ctrl+f5, or clear cache from menu)
You mention changing themes, usually that doesn't require manual refresh. Are you replacing a ZK theme value, or changing a css file?
Anyhow, be aware that the classWebResource library property will slow down your server compared to the default case, since all files located in the class web resource folder (including packaged scripts / styles used by the clients) will be regenerated for every request (every new page navigation, etc).
So, can you give some details on what you are doing? (replacing css file, swapping theme, etc?) and if the clear cache / ctrl+F5 confirms that you have a client side caching preventing you from getting the current version of your resources?
Thanks for reply MDuchemin,
When I open the zul which I want to charge the other theme, I apply the theme using the Library.setProperty("org.zkoss.theme.preferred", theme); Themes.setTheme(Execution.getCurrent(), theme); and setting the Style to the page with the .css (new Style()) Before charging the .zul
Using the library-property (classWebResource.cache on false) don't need to refresh the page on Chrome and FF but on IE doesn't work and I need to refresh the page (don't need to force clear cache, just refresh page) If I change IE options to not save cache it works properly
Hey Softteam,
I got around to test the workflow described on my local machine, but I can't seem to reproduce your issue. Which ZK version are you using? And are you switching between 2 official themes, or your own custom themes?
Hey Softteam,
Still can't get the same result in IE, Best I can see, IE is caching the Css file, since other browsers don't have this issue. If this is the case, you could customize the server output to force the client to refresh a file.
Looking at this resource, they recommend parameters to break cache https://css-tricks.com/strategies-for-cache-busting-css/ In Java, you could try to add a parameter to the files generated by WCSExtendlet https://github.com/zkoss/zk/blob/v8.5.0/zk/src/org/zkoss/zk/ui/http/WcsExtendlet.java Since the theme output by default is always .../zk.wcs, it might be skipped by IE even if the content changes. However, if you return .../zk.wcs?version=themename1, it will be reloaded when changing to ...zk.wcs?version=themename2 If you can change that param dynamically, then you should be able to force download on demand.
or if you are updating the WCSExtendlet anyway, you could just add cache control to the reply to force download every request with something like response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setDateHeader("Expires", 0); // Proxies. But you should be aware that this will waste some performance since you will be re-downloading theme for each page load
This said, if you can find why your IE is caching while other browsers are not, you might save time / implementation work on that side...
Asked: 2017-10-25 19:25:06 +0800
Seen: 89 times
Last updated: Nov 24 '17
ZK 7.0.3 doAfterCompose is not called for GenericForwardComposer
Power of ZK Calender With Charts 2 and Other Components
ZK7 atlantic theme: vlayout/hlayout spacing
Structuring zul-code without includes?
css zk 7.0.3 with ie9 not work
Change listbox MVVM template with Java or how to let user change column order