durusmail: quixote-users: proposition for a better Browser caching mechanism
proposition for a better Browser caching mechanism
2005-05-15
2005-05-17
2005-05-17
2005-05-19
2005-05-22
proposition for a better Browser caching mechanism
vincent delft
2005-05-15
I've got difficulties with date on one of my servers.

Bacause of this the "Expires" header does not work
like it should be.

Here after the result of my investigation in the
oreilly book called "http the definitive guide". They
explaine page 176 that our gracefull old HTTP1.0+
protocol has invented the "Expires" header, but
because    of date synch problems (Hey, I'm not the
only one with this problem ;-) ), HTTP1.1 come with he
"Cache-Control" header.

You see where I will go ;-).

I know that not every browser has implemented the full
http 1.1 protocol recommendations, but caching ... is
not an exotic topic.

And, because majority of browsers (often for security
of performance reasons) propose regularely upgrades, I
consider that the majority of them have implemented
the "Cache-Control" mechanism.

I would just add, that such "caching" is very
interesting for Javascript, Css, and pictures files.
Thus all elements that lynx or links (for example)
cannot treat.


Thus, I propose to implement in "http-response.py"
around line 395, the following code:

"
        # Cache directives
        if self.cache is None:
            pass # don't mess with the expires header
        elif "expires" not in self.headers:
            if self.cache > 0:
                #expire_date = formatdate(now +
self.cache)
                max_age="max-age=%s" % int(self.cache)
            else:
                #expire_date = "-1" # allowed by HTTP
spec and may work better
                max_age="no-store"
                                   # with some clients
            #headers.append(("Expires", expire_date))
            headers.append(("Cache-Control", max_age))
"

(for better readability I've just commented the old
code.


Thanks to let discuss it.
I've tested it with medusa server (should work with
others)


I think it's totally backward compatible.
Or we use the famous "cache_time=xxx" where xxx is the
cache period in seconds, or we use "cache_time=-1" or
"cache_time=0" and they force this page to not be
cached in the browser.


Vincent







__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
reply