Ive recently redesigned my website, new CSS, new graphics for buttons etc. When existing users return to my site I want to make sure they get served the new pages and style sheets and the browsers dont try to load the old stylesheets etc.
Previously my headers looked like this -
I have a header file for the public pages -
<meta http-equiv="expires" content="Tue, 16 Feb 2019 09:00:00 GMT">
<meta http-equiv="cache-control" content="max-age=315360000">
A开发者_如何学编程nd a header file for the pages inside the site (after a user has logged on)
<meta http-equiv="expires" content="Mon, 04 Dec 1999 21:29:02 GMT">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
I'm thinking that its likely that the pages inside the site will be served fresh as the cache control has specified no cache etc. But will my visitors to the public pages still see cached versions? Should I add teh same cache-control tags to the header file for the public pages too?
One other thing i did was to add a query string to the new css file to force a new load -
eg -
<link rel="stylesheet" href="css/styles.css?new" type="text/css" >
Any other good advice / best practices for this?
thanks!
Expires 2019 is quite a commitment. You are saying they need not check for updates for the next 8 years.
So yes, you should at least remove those headers from the public pages, and add the other headers if you want to be 100% sure. If you leave them out browsers will guess how long they can use the cached version based mostly on the last-modified http-header.
You should however only use line 1 and 4. Pragma doesn't do anything (only use client-to-server not server-to-client). Double expires doesn't have any use and -1 is an invalid value.
精彩评论