Merge lp:~andrea.corbellini/lazr.restful/fix-375353 into lp:lazr.restful
Proposed by
Andrea Corbellini
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~andrea.corbellini/lazr.restful/fix-375353 | ||||
Merge into: | lp:lazr.restful | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~andrea.corbellini/lazr.restful/fix-375353 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Francis J. Lacoste (community) | Needs Resubmitting | ||
Review via email: mp+6472@code.launchpad.net |
To post a comment you must log in.
Hi Andrea,
First of all, let me thank you for your prompt initiative in tackling that bug and going through the paperwork to become a Canonical community contributor.
Like we discussed on IRC, it's usually a good idea to have a chat about your strategy to fix the bug with another LP developer.
The approach you took here isn't really appropriate since it would affect all methods invocation (and not only when invoked through the web service). This means that internal calls to the method would also be cached. And since this is a global cache that don't take into account parameters passed, it's really something we want to do.
So for this problem, what we really want is a webservice annotation. These are declarations. The annotation should simply do error
defined in lazr.restful.
checking on the annotation parameters and context of usage. And then stick the
caching duration in the annotation data structure.
In the BaseResourceOpe rationAdapter, you can then use that information to set
Cache-control header on the request response. That will leave caching to the
client which is more efficient overall (it doesn't use server resources, will
save on bandwith. Since parameters are encoded in the URL, that's also fine.)
Only GET operation should be thus cacheable. (So it should be an error to use as_read_ operation.
cache_for() in conjunction with annotation others than
export_
One last item, all branches to be merged should have proper tests. In this restful/ docs/webservice -declarations. txt
case, I suggest you look at src/lazr/
That's where the existing annotations are documented and tested. This should
give you a starting idea.
Don't hesitate to contact me on IRC if you need more information or encounter
any problem.
Again, thanks a lot for your initiative.