Navin Leon
Navin Leon

Reputation: 1166

Do I have to set cache expiration every time on HTML?

I want to set cache expiration for my html page after may be 10days

<META HTTP-EQUIV="expires" CONTENT="Thu, 12 Apr 2012 08:21:57 GMT">

So my question is

  1. What happens after 10days? yes the cache will get expire but do I have to set the expiration date again ?
  2. I there a way to set the day length in number for eg: 10
  3. Am confused here please give me some reference.

Please help...

Upvotes: 3

Views: 10679

Answers (3)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201818

The tag has limited effect. In particular, it does not affect proxies, since they work on HTTP headers and do not parse HTML documents.

After the expiry time, browsers are expected to treat the copy of the page in their caches as stale and not use it but request for the page from the server (if online), at least conditionally (send if modified since such-and-such). This means that after any new request for the page, the copy received should not be cached at all. So yes, you should set a new expiry date, unless you really want to prevent caching.

The Expires header or its meta simulation needs to have a specific time mentioned. There are other ways to affect caches, see http://www.mnot.net/cache_docs/

Upvotes: 3

user1086498
user1086498

Reputation:

You need to use some kind of server-side scripting language (like PHP or ASP or JSP) to set that date dynamically. This is only a 'hint' and browsers may or may not even listen to it.

Upvotes: 2

rid
rid

Reputation: 63560

That is a hint telling browsers that they should keep the HTML in cache until the specified date. That means that, if the browser complies, then whenever it sees the same URL, it will not make a request to retrieve it, but rather it would take the HTML from its cache and show that instead.

Therefore you can safely generate a new time for each request, since the browser that's caching the page won't make the request anyway, and the browsers making the new requests will get an updated hint.

Note though that no one's forcing the browsers to comply, they may simply ignore the hint and make the request anyway.

Upvotes: 1

Related Questions