Closed Bug 753483 Opened 12 years ago Closed 12 years ago

kuma: Support conditional GET headers for document view caching

Categories

(developer.mozilla.org Graveyard :: Editing, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: lorchard, Assigned: lorchard)

References

Details

(Whiteboard: u=contributor c=wiki s=2012-05-22 p=2 t=2012-05-29)

Requesting a document from kuma should support conditional GET headers for caching.

So, when a doc is requested, it should serve up Last-Modified and Etag reflecting the state of the doc.

Later, when a doc is request with the If-Modified-Since and/or If-None-Match headers, and the values match the current state of the requested doc, respond with a 304 Not Modified and no body.

An implementation hint, if a Django decorator doesn't do this already: Optimize by stashing last known Last-Modified and Etag in memcache, keyed on doc full path (ie. {doc-locale}/{doc-slug}) for a quick 304 Not Modified exit as early as possible in the doc view code.
Whiteboard: u=contributor c=wiki s=2012-05-22 p=2
Blocks: 753485
Assignee: nobody → lorchard
After some head-desk-ing, I have discovered: the Django CSRF middleware deletes the ETag header from responses. Luckily, last-modified should be plenty for purposes here.
Commits pushed to master at https://github.com/mozilla/kuma

https://github.com/mozilla/kuma/commit/519c8030c451b52dc30c804cc2063afe33827415
fix bug 753483 - Conditional GET on document view

* Use @condition decorator on document view for conditional GET

* Cache document last-modified as UNIX timestamp

* Invalidate last-modified cache on Document save()

* Give up on ETag, since it gets deleted from outgoing headers by CSRF
  middleware.

* Tests

https://github.com/mozilla/kuma/commit/c5942ddeab7243a63dbe44c8781b7dc38bcc55a8
Merge pull request #214 from lmorchard/753483-doc-conditional-get

fix bug 753483 - Conditional GET on document view
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: u=contributor c=wiki s=2012-05-22 p=2 → u=contributor c=wiki s=2012-05-22 p=2 t=2012-05-29
Version: Kuma → unspecified
Component: Docs Platform → Editing
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.