Jump to content

load fresh content / clear users' cache


toolman

Recommended Posts

Hi,

For some reason, my website has an issue with loading old content until the user refreshes the page. I have read that versioning can help, e.g. adding http://www.website.com/?cache=001

I send out emails as a newsletter and was thinking of adding a parameter ?cache=001 to the links in the email to load the latest content. Would adding this just load the latest content on that specific page, or would any other pages on the site load any new content changes?

Thanks!
 

Link to comment
Share on other sites

Caching does not happen by default - only if something on your server told the browser to cache the content. Versioning isn't really that great of a solution, given that there are others which can cause caching to happen the way you want, and more suited for when you don't have control over the server sending the content (like a CDN).

 

What are the response headers for a page on your site that gets cached? Your browser might have something built-in to see them, or you may need an extension. Caching headers include Last-Modified, ETag, Expires, Cache-Control, and Pragma.

Link to comment
Share on other sites

What kind of content are you talking about? Like actual html, css, javascript, images?  Versioning does work quite well for things like css and javascript, but html should typically be downloaded on each request unless, like stated above, the server is setting a cache that you are unaware of.

Link to comment
Share on other sites

Let me explain just a tiny bit more on the versioning aspect.  The kind of example you show is not great for css and javascript.  I use php to create a version file name and then have htaccess strip it apart to serve the actual file, while allowing the browser to think it's a new file if the versioned file name is different than before.

Link to comment
Share on other sites

Thanks for the replies.

 

I want to avoid browsers - so server side. I'm looking for a code that will just reload the most recent content.

 

I added the following which doesn't wor:

 

<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" />
<script type="text/javascript" src="view-source:http://www.website.com/beta/scripts/jquery.min.js

 

The site is based on ASP and labels files as .shtml - I could find a way of insertin PHP, but its not ideal.

Edited by toolman
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.