Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to avoid cache wit meta tags?

Posted on 2011-02-24
4
Medium Priority
?
600 Views
Last Modified: 2012-06-21
Dear Experts,
I use this code to prevent cache. I want my user to see the latest version of my web site.
I update my web site almost every week.
I'm not sure if the users who use proxy servers see my up-to-date page.
what should I do?
Is this below code enough?
<meta http-equiv="cache-control" content="no-cache" />

<meta http-equiv="pragma" content="no-cache" />

<meta http-equiv="expires" content="0" />
0
Comment
Question by:Braveheartli
  • 2
4 Comments
 
LVL 1

Author Comment

by:Braveheartli
ID: 34968796
My pages are mainly HTML
0
 
LVL 11

Assisted Solution

by:Murfur
Murfur earned 1000 total points
ID: 34969480
Firstly, probably the only (and easiest) way to absolutely guarantee no caching is to change the filename slightly e.g. update-DATE-OF-UPDATE.html i.e. update-240211.html update-250211.html etc.
But this is probably impractical if you have a lot of links that refer to the original, so it really depends on how you have built your site!

META TAGS
META tags are processed in order, so for starters, put your cache related tags at the top of the list.
Also, note that some browsers will still cache a file that tells it not to (Big brother is watching...) but you can use the EXPIRES tag which forces the browser to get an up to date version at the next request for the page.

CACHE-CONTROL
Use of http-equiv="pragma" is effectively deprecated. It is the old HTTP 1.0 compliant method and unless your site visitor is using an obsolete browser like IE5 or Netscape 4 it is not used any more and can usually be ignored. The updated format is http-equiv="cache-control" but you can still use the pragma line to serve older browsers just in case one turns up. After all, in the post-apocalypse wasteland who knows what old computers might be re-activated...

ROBOTS
You may also want to consider blocking search engines from caching the page in their archives by making them ignore the page completely:
<meta name="robots" content="none">

But then you probably still want your site to be found with a search so you can allow indexing and linking (following links to your other pages) but deny archiving:
<meta name="robots" content="index, follow, noarchive">

EXPIRES
You may have seen this tag with a date and time specified. You can ignore the time as this is no longer read, particularly by search engines. But if you use a date then make sure it is in the correct format i.e. Thu, 24 Feb 2011
<meta name="expires" content="Thu, 24 Feb 2011" />

Alternatively, you can set your date to 0 which effectively sets the page as already expired (for those Big Brother browsers)
<meta name="expires" content="0" />

Also note that if you manage the date value properly you can reduce unnecessary workload for your server (remember that cached files will not be requested from the server) i.e. if you always update your page on a Sunday evening set the date at each update for the next weekend so that anyone coming to your site before the next update will have the advantage of cache. This is particularly good for you if you are paying for the bandwith used by your server as I am. I know it is only a few ¢ per meg but it all adds up to several $ over time!
<meta name="expires" content="Sun, 27 Feb 2011" />


So, after all that your page might look something like this:


<html>
	<head>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta name="expires" content="Sun, 27 Feb 2011" />
		<meta name="robots" content="index, follow, noarchive" />
		<title>Page title</title>
	</head>

Open in new window

0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1000 total points
ID: 34969722
I use these two lines and it seems to work just fine.
<meta http-equiv="Expires" content="Mon, 01 Jan 1990 01:00:00 GMT" />
<meta http-equiv="Pragma" content="no-cache">

Open in new window

0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 34991234
Thank u
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question