How to Remotely force a client to purge a cached website?

Louay Cheikh picture Louay Cheikh · Feb 22, 2018 · Viewed 8.9k times · Source

We are experiencing an issue where a previous version of our home page is being displayed. Even though there has been changes since then, the web page will always show the old version.

This issue stems from us using a WordPress plugin that added a Last-Modified: Tue, 19 Apr 2016 15:18:40 GMT header to the response.

The only way found to fix this issue is by force refresh on the browser. Is there a way to invalidate that cache remotely for all clients ?

The Request-Response header

Answer

GeordieShorn picture GeordieShorn · Feb 22, 2018

If you mean the stylesheets or javascript for example you can update the version of the stylesheet see below for an example

<link rel="stylesheet" type="text/css" href="mystyle.css">

You can change to

<link rel="stylesheet" type="text/css" href="mystyle.css?v=1.0">

Notice the ?v=1.0 parameter at the end of the source, this works for Javascript also.

If you need images and things to update you can find lots here about cache busting here

Refresh image with a new one at the same url

you can also try adding

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 20 Feb 2012 00:00:01 GMT">

To the Head of the HTML Page.