On Jun 12, 2007, at 2:53 PM, Mike Orr wrote:

>
> 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


>
> 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
>

The problem here is that no etag header is sent to the browser. I  
don't understand why, from the code above there should definitely be  
one there.

>
> 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?
>

Browsers will always check back to make sure a etag/lastmodified  
cache page hasn't expired. You want to also use the Expires header  
which tells the browser when it actually needs to check back

--
Philip Jenvey



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to