?
Solved

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

Posted on 2014-01-09
11
Medium Priority
?
239 Views
Last Modified: 2014-10-22
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!
0
Comment
Question by:it1000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
11 Comments
 
LVL 12

Expert Comment

by:aindelicato
ID: 39768631
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
?>
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39768879
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.
0
 

Author Comment

by:it1000
ID: 39769434
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.
0
Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39769481
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.
0
 

Author Comment

by:it1000
ID: 39769890
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?
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39769970
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.
0
 

Author Comment

by:it1000
ID: 39769998
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.
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 39770128
Technically, the browser makes a 'conditional' GET request with "If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field."  http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html  The server response if the server sees no change in the file date is a "304 Not Modified".

Here is the RFC on caching: http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13

Thru FTP or a script on the server you can change the date of the files.  While in theory that should work, I know from experience that it doesn't always work.  This is especially true of files that are loaded from the HTML file like images and javascript.  I have at times had to load an image or javascript directly in the browser and then do a Ctl-F5 refresh to get it to update.

This http://www.paulund.co.uk/set-expire-headers-in-htaccess appears to be a decent article on setting expiration times in '.htaccess'.

Still... I don't know of anything that will override what is already in your cache.  Everything I know of applies to the Next time you load the file.
0
 

Author Comment

by:it1000
ID: 39770221
I tried touching all the files. Didn't help.

Anyone have any ideas?
0

Featured Post

Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question