ensuring a page is not stored in cache

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
IMPORTANT NOTE!!

DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.



PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
Post Reply
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

ensuring a page is not stored in cache

Post by bowlesj »

Hi, is there a switch somewhere that can be set to ensure a page does not get stored in cache on the user's machine so I don't have to tell them to press F5 to be sure they have the latest data. I was thinking of putting the code in javascript to simulate the user pressing F5 (do a reload) and such that it does it once only but it would be better if I could avoid that one extra flash on the page if possible. It seems to be a big issue that a lot of people have concerns about so I figured you might have come up with something. I tried pocking around but did not see anything.

Thanks,
John
User avatar
Pablo
 
Posts: 22489
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: ensuring a page is not stored in cache

Post by Pablo »

You can try this:

Code: Select all

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

Thanks Pablo,
John
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

The code above eventually showed it did not work so I put the code below in last night. The code does put the # at the end of the URL so that much is working and it happens so fast I can't see it occurring so that is good. I will find out after a day or two if my daily test updates actually get drawn in so users can see them without having to press F5. If this one does not work I have a few others I found on the web that I can try.

Code: Select all

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css" />

<script>
function funcOnloadProcessing() {

   //START: code to force an F5 refresh
   $(document).ready(function(){    
       //Check if the current URL contains '#'
       if(document.URL.indexOf("#")==-1){
           // Set the URL to whatever it was plus "#".
           url = document.URL+"#";
           location = "#";
   
           //Reload the page
           location.reload(true);
       }
   });
   //END: code to force an F5 refresh

}
</script>
Last edited by bowlesj on Fri Sep 16, 2016 10:54 am, edited 1 time in total.
User avatar
BaconFries
 
 
Posts: 5648
Joined: Thu Aug 16, 2007 7:32 pm

Re: ensuring a page is not stored in cache

Post by BaconFries »

Note that the example you have shown uses javascript/jquery which is ok in its own right but if the user has disabled this in the browser then it simply wont run. So if any code that you find that uses javascript/jquery means your pages will still be cached on the endusers PC.
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

Hi BaconFries, thanks for reminding me. I just double checked my page and I do have that concerned covered off with this code. John

Code: Select all

<noscript>
<p>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
This website will not run properly without javascript enabled. Please enable javascript and try again.<br>
</p>
<style>
/* This CSS code is to make your layer hidden when it first goes out */
#AdvancedButton_Login {  
    display:none
}
#Form_Register {  
    display:none
}
</style>
</noscript>
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

I was still struggling with this issue in that I did not like the javascript double read of the php code. So I did more research and I found what appears to be the solution to Pablo's very first suggestion. I posted this info to another thread and copied it below.
=================================
Regarding the question I have, I came up with a simple google search "how to stop web page caching". If found the page below.
http://www.htmlgoodies.com/beyond/refer ... he-Huh.htm
He mentioned two of the commands I was using the first time around and explained why they do not work.
He seems to have researched it fairly well so I am going to try this for a few days to see if it ever fails.

Also this worked well to clear the cache of the pages for my webiste so I can see if they are getting in cache now by using the chrome://cache/ command
http://superuser.com/questions/278948/c ... -in-chrome
Here is the useful extracted item from the above link:
Open up a page on the website you want to clear the pages for.
in google chrome just left of the URL box click on the "reload page" button but hold it until you see a little menu of three or so items.
From the popup list, choose "Empty Cache and Hard Reload".
Not sure this clears the cache for the entire domain. But probably satisfies 90% of the use cases of people that visit this SE question.
Note: In some cases this will NOT open the popup list. This is because the page isn't cached at that time, so the menu is not invoked.

These instructions from Google actually worked for clearing the pages from google chrome cache so I can test the new html code:
Open Chrome.
On your browser toolbar, click More More.
Point to More tools, and then click Clear browsing data.
In the "Clear browsing data" box, click the checkboxes for Cookies and other site and plug-in data and Cached images and files.
Use the menu at the top to select the amount of data that you want to delete. Choose beginning of time to delete everything.
Click Clear browsing data.

This has a lot of info.
http://stackoverflow.com/questions/4954 ... l-browsers
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

I finally got this to work for both Chrome and Firefox (that is all I care about at this point at least). It was not easy. I worked at 26 page change test to test this. Firefox would not work until I put in "must-revalidate" but Chrome would work without this.. Chrome would not work if I had them out of sequence. What this does is force the browsers to check the server every single time to see if the page has changed so I can be sure the user is getting the most recent update.

Code: Select all

<meta http-equiv="cache-control" content="no-cache, public, max-age=86400, must-revalidate">
<meta http-equiv="expires" content="0">
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
And this also works on both Chrome and Firefox to set the max-age to 7 days. However the 7 days part is assumed okay. Only the 26 change tests were done.

Code: Select all

<meta http-equiv="cache-control" content="no-cache, public, max-age=604800, must-revalidate">
<meta http-equiv="expires" content="Tue, 01 Jan 2099 1:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
Lastly the web hosting company tweaked the etag flags a bit at the server end. This may have helped. However the Firefox still needed the in "must-revalidate" before it worked.
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

The last set of meta statements failed on chrome about 3 days later so I simplified the statement to the statement below and it has been working as per the tests below.
<meta http-equiv="cache-control" content="no-cache, public, max-age=0, must-revalidate">

16 tests per browser.
2016/Oct/12 Chrome failed, Firefox passed. (because chrome failed I simplified the meta statement to have a single line and an expires of zero)
2016/Oct/12 Chrome passed, Firefox passed.
2016/Oct/13 Chrome passed, Firefox passed - Chrome passed, Firefox passed.
2016/Oct/14 Chrome passed, Firefox passed - Chrome passed, Firefox passed.
2 days without tests
2016/Oct/17 Chrome passed, Firefox passed - Chrome passed, Firefox passed.
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

Sadly Chrome just failed repeatedly while Firefox continues to work flawlessly. After reloading two pages on Chrome it started to work during my test. It seems every few days Chrome fails then it starts working again for a few days. The web pages are ultra simple and except for my test changes the webpages are exactly the same. I see no reason to beat my head against a wall trying things when FireFox works flawlessly so I have sent two messages to Chrome support telling then that Firefox works flawlessly while their browser fails every so often (I sent the actual full page too). I also told them I am going to tell my users exactly what is happening and advise them to use Firefox. Hopefully that will get their attention.
bowlesj
 
 
Posts: 33
Joined: Tue Aug 12, 2014 6:59 pm

Re: ensuring a page is not stored in cache

Post by bowlesj »

I finally got back to this issue and tried the .htaccess code below with Google Chrome. It works. I did 10 days of tests with 12 tests a day for 120 tests in total. I stripped out all the other code.

<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
quang-GTI
 
 
Posts: 2
Joined: Sat Feb 02, 2019 6:58 am

Re: ensuring a page is not stored in cache

Post by quang-GTI »

Pablo wrote: Tue Sep 13, 2016 2:25 pm You can try this:

Code: Select all

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
Dear Pablo
Could you please advice show to use this code? where can I insert it into my webpage?
Thanks and Regards
Quang
User avatar
BaconFries
 
 
Posts: 5648
Joined: Thu Aug 16, 2007 7:32 pm

Re: ensuring a page is not stored in cache

Post by BaconFries »

Could you please advice show to use this code? where can I insert it into my webpage?

Page Properties and inserting into Meta Tags>Meta Tags>User Define"
Post Reply