We (as developers) nonchalantly refreshed the page and happily continued, others didn't and we quickly realised that "Oh, they just need to refresh the page" wasn't good enough.
Solution
We needed a way to make the users refresh their browser caches, but how since we have no control over their browsers?I came up with a bit of JavaScript that will do a hard refresh of the page and use cookies to record that it has been refresh and ensure that it only happens once and doesn't go into an infinite loop.
Here is some code I came up with:
//jquery plugin for cookies <script type="text/javascript" src="/js/jquery/jquery.cookies.2.0.1.min.js"></script> <script type="text/javascript"> //give it a new name each time you need to do this var cookieName = 'refreshv1'; //check client can use cookies if ($.cookies.test()) { //get the cookie var c = $.cookies.get(cookieName); //if it doesn't exist this is their first time and they need the refresh if (c == null) { //set cookie so this happens only once $.cookies.set(cookieName, true, { expires: 7 }); //do a "hard refresh" of the page, clearing the cache location.reload(true); } } </script>Feel free to work with this code but please do not use it without testing or ensuring it is right for your situation. It is merely an idea that worked for me.
It's easier to append a query string to the stylesheet link. I believe the same applies to images and javascript files too.
ReplyDeletePete
Ha. Yeah that's true, good plan. This turned out to be a non-issue for us in the end but thought the code was still interesting
ReplyDeleteHi Colin
ReplyDeleteDoes this work the same with meta tags?
META HTTP-EQUIV="Pragma" CONTENT="no-cache"
META HTTP-EQUIV="Expires" CONTENT="-1"
@Colin - Meta Expire will only affect the current page you are on; not what was previously cached by the browser. It works well in most cases but will not work 100% onLoad.
ReplyDelete@Seffy *correction
DeleteTHANK YOU SO MUCH!!! This solves my problem.
ReplyDeleteHi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru JavaScript Online Training India. Nowadays JavaScript has tons of job opportunities on various vertical industry.
ReplyDeleteLatest sports news headlines from India and world. Check out today's most recent & up-to-date news coverage, videos & photos at thesportsrumour.com
ReplyDeletesports news
I am happy to find this post very useful for me, as it contains lot of information.
ReplyDelete1337x
Permainan slot yang paling banyak diminati oleh semua orang, tentunya disitus kami dengan permainan slot terlengkap, pastinya akan membuat kalian betah permainan slot apa yang kalian dulu mainkan tentunya akan ada disini. silahkan kunjungi situs kami
ReplyDeletehttp://www.slotvivo.net/
http://www.slotvivo.net/daftar-vivo-daftar-slot-vivo-online-android/
http://www.slotvivo.net/link-login-slot-vivo-cara-login-vivo-slot/
http://www.slotvivo.net/deposit-vivo-slot-deposit-slot-pulsa/
http://www.slotvivo.net/withdraw-vivo-slot-agen-resmi-slot-vivo/
http://www.slotvivo.net/livechat-vivo-operator-vivo-slot/
http://www.slotvivo.net/aplikasi-slot-vivo-link-download-vivo-slot/
Great Article
ReplyDeleteCloud Computing Projects
Networking Projects
Final Year
Projects for CSE
JavaScript Training in Chennai
JavaScript
Training in Chennai
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals,
Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer.
Angular Training
Excellent read, Positive site, where did u come up with the information on this posting? I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work,If anyone interested similar one's have a look here thanks.
ReplyDeleteshih tzu puppies for sale near me
buy puppy online
fuhrerschein-kaufen-schweiz