Christopher Arndt wrote:
> You could try setting a few cache-control
> headers (e.g. 'Expire' and friends) in your JSON response like this
>
> import cherrypy
> from time import strftime , gmtime, time
>
> time_fmt = '%a, %d %b %Y %H:%M:%S GMT'
> cache_seconds = 0
>
> @expose('json')
> def add_item(self, *params, **kw):
>     now = time()
>     cherrypy.response.headerMap['Last-Modified'] = \
>       strftime(time_fmt, gmtime(now))
>     cherrypy.response.headerMap['Expires'] = \
>       strftime(time_fmt, gmtime(now + cache_seconds))
>     ...
>     return dict_for_json

This sounds like the best solution to me (and the most true to HTTP).
Setting the 'Expires' header to zero should also work.  From RFC 2616:

"HTTP/1.1 clients and caches MUST treat other invalid date formats,
especially including the value "0", as in the past (i.e., "already
expired")."

That is what I do in my responses that I don't want IE to cache and it
works well.

Christian
http://www.dowski.com


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to