Link to home
Start Free TrialLog in
Avatar of it1000
it1000

asked on

How to bust website's cache serverside? It's showing the old version.

Hello,

I have a wodpress site that I recently migrated from a dedicated server to cloud servers. It was still showing me the old version (new content wasn't appearing) on my computer so I cleared cache and that fixed it.

On my phone it still shows the old version that doesn't have the latest content. A few friends have also told me they see the old version, so I am guessing a lot of my old visitors see the same thing.

How can I solve this? I tried putting this in the header.php of the site on the old and new server:

<meta Http-Equiv="Cache-Control" Content="no-cache">
<meta Http-Equiv="Pragma" Content="no-cache">
<meta Http-Equiv="Expires" Content="0">

Open in new window


But it hasn't helped.

DNS records properly point to the new site.

How do I fix this cache issue?

Thank you!
Avatar of aindelicato
aindelicato

do you have any cache plugins installed like Super Cache?

See this site:
http://wp.tutsplus.com/tutorials/scaling-caching/wordpress-caching-plugins/



Disabling Browser Cache in HTML
With this code placed in the top of the head section you can turn off client side caching.
1
2
3
4
5
<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" />

Disabling Server Side Cache in PHP
This little two liner code goes to the uppermost part of a PHP file.
1
2
3
4
<?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
Avatar of Dave Baldwin
Those are good suggestions and i use them myself.  The trouble with all of those methods is that they don't take effect until the current cached items expire.  The server can not clear the browser cache.  It can only 'ask' that the page not be cached when it is finally loaded from the server.  

Note that the purpose of caching is to speed up web browsing.  If you set it up so that nothing is cached, you force the browser to go back to the server for everything which is slower.  In addition, preventing caching of the HTML does not stop caching of images and javascript.  I frequently change the name of the images or javascript in a new version of a page so that the page will fetch the new versions of images and javascript too.
Avatar of it1000

ASKER

Thank you for your replies. I just want to get over this hurdle then I will set things back to normal.

I tried putting that code in the headers of both the old and the new site, didn't help.

Also, this may give you a clue:

I logged into the old site, deleted the latest articles, and refreshed the site on my phone. If it was indeed pulling from the old site, then the latest articles should disappear since I deleted them. But they still do appear.

How can I basically make the site convince my phone's browser to refresh the content?

I also thought it might be DNS related so I check the domain ttl but it's 1 hour, so it can't be. I migrated the site days ago.

Thank you for your help with this pesky issue.
The cache that is giving you a problem is in your browser on your computer and phones.  Nothing you do on the server will have any effect until you are able to load a new page from the server and not from your cache.  This is a problem I run into all the time when I upload a new pages for a website.

You have to look up the method for forcing your browser to do a complete refresh from the server.  In IE and Firefox on the desktop, it would be Ctrl-F5.  I don't know what it would be on your phone.
Avatar of it1000

ASKER

I did CTRL-F5 and it didn't help.

Also, I deleted everything in /wp-content/cache

Even if CTRL-F5 worked, I cannot ask all my visitors to do CTRL-F5

The only thing that has worked so far is clearing my cache in Chrome. Sure, it solves the problem for me, but the real problem is my visitors.

There has to be a way, no?
No, no way.  The server can Not clear what is in the client's cache.  All it can do is ask it not to cache the page... when it finally gets a new copy.  

Even more to the point, the server can not do Anything to the client except respond to requests.  And the browser on the client will only ask for a new copy of the page when the cached copy expires or you tell it too.
Avatar of it1000

ASKER

Good point, I've been digging around and I think that making the browser believe all files have been recently modified will make it request new versions, which would effectively solve the problem.

How can I force Last-Modified in htaccess? Basically I want every request to tell the browser that the file in question has been modified today!

Any other ways? Can I change the last modified date for all files for my site, alternatively? If so how?

I think this should solve the problem.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of it1000

ASKER

I tried touching all the files. Didn't help.

Anyone have any ideas?