I'm trying to cache a controller method in both the server and
browser. One twist is it's a text document (a tab-delimited file).
Beaker caching is working on the server end (with 1 hour expire time):
from pylons.decorators.cache import beaker_cache
@beaker_cache(key=None, expire=CONFIG["cache.data"], type="file",
query_args=False)
def map_markers(self):
...
But ETAG caching is not working:
encoding = "utf-8"
resp = etag_cache("map_markers")
resp.headers["content-type"] = "text/plain; charset=%s" % encoding
for inc in model....:
lin = "%s\t%s\n" % ...
lin.encode(encoding, "replace")
resp.write(lin)
return resp
When I press reload, the file is fetched from the server, and the
output headers show no caching options or 304:
http://localhost:5000/map_markers
GET /map_markers HTTP/1.1
Host: localhost:5000
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3)
Gecko/20061201 Firefox/2.0.0.3 (Ubuntu-feisty)
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: beaker.session.id=90cdc56ab4015b90ec4e24a979331662
Cache-Control: max-age=0
HTTP/1.x 200 OK
Server: PasteWSGIServer/0.5 Python/2.5.1
Date: Tue, 12 Jun 2007 21:47:49 GMT
Content-Type: text/plain; charset=utf-8
Connection: close
I'd like the browser to cache this page and not bother the server
again for an hour or a day. Is etag_cache supposed to do this or do I
have to set the HTTP headers manually?
--
Mike Orr <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---