Fix and improve some caching in our views.

Review Request #7167 — Created April 5, 2015 and submitted

Information

Review Board
release-2.0.x
cfafd0a...

Reviewers

There were some areas where we weren't doing a great job of handling
caching or generating ETags. We also had a bug in a recent change that
prevented us from having reliable ETags.

The recent addition of TEMPLATE_SERIAL didn't end up creating a stable
serial. The assumption the code made was that a call to
generate_ajax_serial() would always re-calculate the proper value based
on the modified time of the templates, but this actually only happens
the first time. That meant that every time initialize() was called, we'd
change TEMPLATE_SERIAL, making it unstable. We're a bit more careful
now to only set this once.

We had some less-than-optimal ETags, which basically just exposed some
state, generating longer and longer ETags as we added to them. We now
compute a hash based on these values.

We also had a couple cache checks based on the Last-Modified timestamp,
but this isn't a great thing to base caching off of. They're not
flexible, and they come with precision issues and can end up being
ignored based on other headers. We now use ETags instead.

Unit tests pass.

Verified that I got repeated 304s on these views, so long as the source of
the ETags did not change.

This also fixed the odd little bug with the Review Request Last Update URL,
where every other request would return a 200 instead of a 304.

Description From Last Updated

'reviewboard' imported but unused

reviewbotreviewbot

'get_modified_since' imported but unused

reviewbotreviewbot

'set_etag' imported but unused

reviewbotreviewbot

'http_date' imported but unused

reviewbotreviewbot

'reviewboard' imported but unused

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/webapi/resources/review_request_last_update.py
        reviewboard/__init__.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/webapi/resources/review_request_last_update.py
        reviewboard/__init__.py
    
    
  2. reviewboard/__init__.py (Diff revision 1)
     
     
    Show all issues
     'reviewboard' imported but unused
    
  3. reviewboard/reviews/views.py (Diff revision 1)
     
     
    Show all issues
     'get_modified_since' imported but unused
    
  4. Show all issues
     'set_etag' imported but unused
    
  5. Show all issues
     'http_date' imported but unused
    
  6. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/webapi/resources/review_request_last_update.py
        reviewboard/__init__.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/views.py
        reviewboard/webapi/resources/review_request_last_update.py
        reviewboard/__init__.py
    
    
  2. reviewboard/__init__.py (Diff revision 2)
     
     
    Show all issues
     'reviewboard' imported but unused
    
  3. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.0.x (f6c9b29)