Merge lp:~leonardr/lazr.restful/cache-service-root into lp:lazr.restful
Status: | Merged |
---|---|
Approved by: | Gavin Panella |
Approved revision: | 126 |
Merged at revision: | not available |
Proposed branch: | lp:~leonardr/lazr.restful/cache-service-root |
Merge into: | lp:lazr.restful |
Diff against target: |
217 lines (+145/-2) 5 files modified
src/lazr/restful/NEWS.txt (+12/-0) src/lazr/restful/_resource.py (+30/-2) src/lazr/restful/example/base/root.py (+1/-0) src/lazr/restful/example/base/tests/root.txt (+88/-0) src/lazr/restful/interfaces/_rest.py (+14/-0) |
To merge this branch: | bzr merge lp:~leonardr/lazr.restful/cache-service-root |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella | Approve | ||
Review via email: mp+22948@code.launchpad.net |
Description of the change
This branch gets lazr.restful to set the Cache-Control header when serving a representation of the service root. This is a big win because the service root only changes when you deploy a new version of your lazr.restful application (eg. Launchpad), but every user makes 2 requests for it every time they start up lazr.restfulclient.
There are two 'max-age' times set in the Cache-Control header: one for the latest version of the web service (which changes more often) and one for all other versions. By default, the max-age for the latest version is one hour and the max-age for all other versions is one week.
After the max-age expires, the client will make a *conditional* request to see whether the service root has changed. If it hasn't, I believe the client will update the client-side max-age and not make any requests for another hour (or week). But I need to check to make sure httplib2 actually does this.
Nice branch. Conversation from IRC:
<allenap> leonardr: Is there any way config. active_ versions could be empty?
<leonardr> allenap: no, that would prevent lazr.restful from starting up
<allenap> leonardr: Instead of having [604800, 3600], could you have a module-level constant like `HOUR = 3600 # seconds`, then the default can be specified as [7 * 24 * HOUR, 1 * HOUR]?
<leonardr> sure