Re: best practices on setting HTTP headers and status codes
Sean Upton <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.devel |
|---|---|
| Message-ID | <CANjV-2P13RECbgXT0hUi19dy7N4AscTjZLT_0Cn_DqK_ASYHHw@mail.gmail.com> |
On Thu, Sep 11, 2014 at 2:55 PM, Héctor Velarde <[email protected]> wrote: > what I want is to return a 304 status code if the view has not changed since > the last time the client got it. as I want to be a good citizen, I want to > handle this with and without proxies (Varnish). > > to solve this problem I'm handling the "If-Modified-Since" request header > and, while working on that, I found some code in different parts of the > Plone core code that handles similar situations; an example, for images, can > be found here: I am sure I have not thought this through entirely, but could you set the Vary header in the response for the If-Modified-Since request header? OTOH, that may have the practical effect of making cache hits pretty unlikely. One alternative: leverage traversal semantics by making your view provide IPublishTraverse, where you have a URL path like this: /path/to/liveblog-post/@@since/2014-09-12T15:20 Making YourView.publishTraverse() do the fun work of parsing the ISO8601 stamp, and setting internal datetime.datetime attribute on the view object, then having the YourView.__call__() method calculate and return the result. Then you have a URL you don't have to worry too much about headers for re: caching? If you do this on a one-minute granularity, high traffic ought to leverage Varnish HITs (but even then, maybe you can make the caching interval configurable to more or less granular). Sean ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ Plone-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/plone-developers