Force client-side update after site update

Asked

Viewed 4,539 times

9

The scenario of my problem is this, I have a website that has been updated, but some customers are reporting that the update was not made for them, which are still in the old model of the site (probably by the persistence of cache).

I’ve done several updates and never had that problem. I don’t know if it was the size of the update (basically a re-work of the whole project) that is implicating this problem, but I can’t get users to access the new version of the site.

I know to clean up the cache, Ctrl+F5, Ctrl+r may help, but not feasible...

I already make use of the version practice in the files, for example:

scr="meuscript.js?v=0123456"

href="meuestilo.css?v=0123456"

I also use some tags in HTML, such as:

<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

But nothing has produced the desired effect. I confess that it is an area that I do not possess much experience and knowledge. So, what could I do to get the desired result? That is, force the page update (or cache) on the client side?

  • a dummie parameter in the url does this...

  • @andrepaulo some example?

  • if your url has no parameter ?a=1 for example... if you have &a=1 see if it helps you... but every time Voce wants updated the number changes, or the parameter changes... each different url causes the browser to update

  • @andrepaulo was not the case... Remains the same thing.

  • Question: Have you entered the tags before or after cache control problem appears? If it was later, it would take clearing the cache to update them to the version with these tags.

  • @Andersoncarloswoss I started using from this update. That is, in the previous version did not exist and this exists. But even so, it wouldn’t make the file read differently?

Show 1 more comment

3 answers

4


Something I saw in that soeng’s response

Taking the part that really matters:

When these values are provided through the response headers of the requests, they take precedence over the tags <meta>. some servers send default values, so it is advisable to send along to answer the headers explicitly.

You can check what is coming using Devtools by going to the tab Network > clicking on your page request > check the header Cache-Control in the section Response Headers flap Headers side panel.

Using PHP:

header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.

Using Java Servlet, or Node.js:

response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.

Using ASP.NET-MVC

Response.Cache.SetCacheability(HttpCacheability.NoCache);  // HTTP 1.1.
Response.Cache.AppendCacheExtension("no-store, must-revalidate");
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0"); // Proxies.

Using ASP.NET:

Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0"); // Proxies.

Using ASP:

Response.addHeader "Cache-Control", "no-cache, no-store, must-revalidate" ' HTTP 1.1.
Response.addHeader "Pragma", "no-cache" ' HTTP 1.0.
Response.addHeader "Expires", "0" ' Proxies.
  • Well then, I already tried this and it did not help. In my question I inform that I have tried it.

  • with all caching control? Contents?

  • another thing mentioned is to send in the Answer this data, which server language is using?

  • I’m using PHP and I’m also trying to test those extra parameters (I hadn’t noticed)

  • What? It worked man? sending headers in reply?

  • I am testing.. It is something difficult to test in a real environment of use, because I need to check on other computers, etc. But at first yes! One thing that left me in doubt was also Anderson’s comment on the question. Do you know if this can interfere?

  • his question is solved this way, since when Voce sends the headers by Sponse it will take precedence over the meta tags.

Show 2 more comments

1

Friend, a very simple solution is to rename the HTML/CSS/JS files that have been modified (and of course, change where they are also called), so the browser does not recognize anything in cache and loads the files fresh.

-1

One method to force the browser to clear the cache is the HTML5 cache app. You create a Manifest file where you write what should be cached and what should not be cached.

ALWAYS that the manifest file is updated, the resources will be UPDATED. (don’t forget to clear as much meta tag as you used on cache) an example of manifest:

CACHE MANIFEST
# 2012-02-21 v1.0.0
/theme.css #em cache
/logo.gif # em cache
/main.js # em cache

NETWORK:
login.asp #nunca será mantido em cache

FALLBACK:
/html/ /offline.html

Take a look if it helps you:

http://www.escolaw3.com/html/html5-cache-app

  • I read about it. But I also saw that its use is no longer recommended due to support discontinuity. Reference. I could be wrong, but it wouldn’t be the same thing you recommended?

  • Well, you must have read it on the ne Mozilla? take a look at this text: http://www.andygup.net/application-cache-is-not-gone-oh-my-or-is-it/ Things aren’t quite like that, and application cache at least will still be maintained for years to come... You can use it fearlessly, it’s part of HTML5, probably by the time they remove your site will have been redone (again)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.