Questions on Expires header, CacheFu and must-revalidate

2 Messages Forum Options Options
Permalink
Manuel Vázquez Acosta
Questions on Expires header, CacheFu and must-revalidate
Reply Threaded More
Print post
Permalink
I've been reading the specs of HTTP 1.1: They say:

"If an origin server wishes to force any HTTP/1.1 cache, no matter how
it is configured, to validate *every* request, it SHOULD use the "must-
revalidate" cache-control directive (see section 14.9)." [My bolds]

However, CacheFu indicates in its UI:

"Cache-Control Header: must-revalidate
Must objects be revalidated with the server (by a conditional GET) once
they have expired in the client?"

In an typical scenario like this:
 1. User A requests http://www.example.org/
 2. The Squid receives it, MISS it and request it to the Origin Server
 3. Origin Server responses with a Cache-control like the default
cache-in-proxy-1-hour (maxage: 0, s-maxage: 3600, must-revalidate)
 4. Squid receives the response, caches it, and sent it back to User A.

In less than an hour:
 1. User B requests http://www.example.org/
 2. Squid receives it, it has it fresh with the must-revalidate.
QUESTION: Does it revalidates it right away with a conditional GET, or
serves the page from the cache?

QUESTION: Should I remove must-revalidate, in order for the cache to
serve fresh pages from cache instead of revalidating? What are the pros
and cons?


On the other hand, I see an Expires header been sent:
Expires: Tue, 07 Jul 1998 12:07:59 GMT

The specs says:
"If an origin server wishes to force a semantically transparent cache to
validate every request, it MAY assign an explicit expiration time in the
past. This means that the response is always stale, and so the cache
SHOULD validate it before using it for subsequent requests."

But also says that:
"[Cache-control] directives typically override the default caching
algorithms."

I'm not sure is this Expires header is due to page template, or because
CacheFu inserts it. Also, not sure if this Expires is been taking into
account.

Any help will be appreciated.

Best regards,
Manuel.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Plone-Users mailing list
Plone-Users@...
https://lists.sourceforge.net/lists/listinfo/plone-users
Ricardo Newbery
Re: Questions on Expires header, CacheFu and must-revalidate
Reply Threaded More
Print post
Permalink

On Jul 4, 2008, at 9:15 AM, Manuel Vazquez Acosta wrote:

> I've been reading the specs of HTTP 1.1: They say:
>
> "If an origin server wishes to force any HTTP/1.1 cache, no matter how
> it is configured, to validate *every* request, it SHOULD use the  
> "must-
> revalidate" cache-control directive (see section 14.9)." [My bolds]
>
> However, CacheFu indicates in its UI:
>
> "Cache-Control Header: must-revalidate
> Must objects be revalidated with the server (by a conditional GET)  
> once
> they have expired in the client?"


Yes, this line in the specs can be a bit misleading.

The "must-revalidate" token is used to flag when a cache must not use  
a *stale* cached entry without first revalidating.  Stale in this case  
is limited to whatever is implied in the Expires or max-age value.  If  
there is no Expires or max-age, then this token implies that *every*  
request be validated.

In theory, caches can apply their own heuristics that keep  
revalidation from happening after an item has become stale (some  
client cache-control can do this also) so this token is used to flag  
when you want to strictly adhere to the server-generated expirations.  
In practice, leaving off the must-revalidate token is often  
inconsequential.



> On the other hand, I see an Expires header been sent:
> Expires: Tue, 07 Jul 1998 12:07:59 GMT
>
> The specs says:
> "If an origin server wishes to force a semantically transparent  
> cache to
> validate every request, it MAY assign an explicit expiration time in  
> the
> past. This means that the response is always stale, and so the cache
> SHOULD validate it before using it for subsequent requests."
>
> But also says that:
> "[Cache-control] directives typically override the default caching
> algorithms."
>
> I'm not sure is this Expires header is due to page template, or  
> because
> CacheFu inserts it. Also, not sure if this Expires is been taking into
> account.


This is intentional behavior.  Since you have max-age=0, CacheFu also  
sets an Expires header in the past.  However your cache proxy will  
obey s-maxage=3600 instead.

Ric




-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Plone-Users mailing list
Plone-Users@...
https://lists.sourceforge.net/lists/listinfo/plone-users