Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 427
Louay Cheikh Avatar asked Feb 22 '18 14:02

Louay Cheikh


1 Answers

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.

like image 112
GeordieShorn Avatar answered Oct 25 '22 16:10

GeordieShorn