0

Avoid cleaning browser cache to update Javascript after a deploy

asked 2016-10-04 09:59:14 +0800

eclipse1 gravatar image eclipse1
21 4

updated 2016-10-06 09:28:35 +0800

Sometimes between deploys we have to change our javascript files (Example: we add a new function for a custom component to use) and if we don't clean the cache of the browser a javascript error will occur saying the new change isn't defined.

Is there a mechanism in zk to avoid this error by refreshing the javascript sources? I would like to avoid asking users to clean the cache of their browsers after a deploy.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-10-06 15:40:11 +0800

Darksu gravatar image Darksu
1991 1 4

Hello eclipse1,

A trick you could using DspFns.setCacheControl(String, int). This is used to set the Cache-Control

https://www.zkoss.org/wiki/ZKDeveloper'sReference/PerformanceTips/MinimizeNumberofJavaScriptFilesto_Load

Another options but a little more advanced is to update your query string parameter in order to version the resource. For example:

<script>document.write('<script src="/myJavascript.js?dev=' + Math.floor(Math.random() * 100) + '"\><\/script>');</script>

Best Regards,

Darksu

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2016-10-04 09:59:14 +0800

Seen: 29 times

Last updated: Oct 06 '16

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