Re: best practices on setting HTTP headers and status codes
Nathan Van Gheem <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.devel |
|---|---|
| Message-ID | <CAL8hw9EDaV9szXxsd16Pcf-d6D8EzxZa=W4+OyVTsSHeKq7b0w@mail.gmail.com> |
You don't have to use plone.app.caching for everything IMO. In many cases, I do custom cache headers in views. Seems like a fine thing to do to me... On Thu, Sep 11, 2014 at 4:17 PM, Sean Upton <[email protected]> wrote: > 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 > Plone-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/plone-developers > -- Nathan Van Gheem Solutions Architect Wildcard Corp ------------------------------------------------------------------------------ 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 Plone-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/plone-developers