Refresh external JS file/data changes.
What is the best method to assure that the latest external JS or ajax text file changes
are recognized so that older cached information is not used in error?
Is there a force JS to reload command?
cookie or local storage settings?
Is this something solvable with JS or is a browser setting by the user/client necessary?
its up to the server to use traditional http cache headers to effectively instruct the browser.
in particular, a Date header is always required.
if you want no cache, send an expires tag set the same as Date or to a gmt date in the past.
cache-control: private will help with fringe-case older proxies that don't get http1.1, but all browsers since ie7 understand 1.1.
if you want to not always check for new ones, but want to periodically check for updates, you can set expires to 4 hours in the future, and use the max-age directive in cache-control. this helps performance a lot (compared to always-loading) while ensuring that the client will get a fresh copy the next time they come back to the site.
read up on headers, trust that they work, and you will have few problems assigning the specific and desired behaviors to your script loading.
you can see how good sites setup headers using firebug, and what effect a 200, 304, and far-future-expires headers have on page load performance.
one last thing: don't change the url every time, it's bad for your user's data plan consumption and your site's performance.
Last edited by rnd me; 12-20-2012 at 03:09 AM.
Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com
Thank you, 'rnd me', for the information and cautions.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)