kuma: Support conditional GET headers for document view caching

RESOLVED FIXED

Status

developer.mozilla.org
Editing
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: lorchard, Assigned: lorchard)

Tracking

Details

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

(Assignee)

Description

6 years ago
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.
(Assignee)

Updated

6 years ago
Whiteboard: u=contributor c=wiki s=2012-05-22 p=2
(Assignee)

Updated

6 years ago
Blocks: 753485
(Assignee)

Updated

6 years ago
Assignee: nobody → lorchard
(Assignee)

Comment 1

6 years ago
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.

Comment 3

6 years ago
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

Updated

6 years ago
Status: NEW → RESOLVED
Last Resolved: 6 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: Mozilla Developer Network → Mozilla Developer Network
You need to log in before you can comment on or make changes to this bug.