-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache etags #7107
Cache etags #7107
Conversation
Codecov Report
|
I'll add that I've gone through a bit and not seen that calling |
As @rtibbles pointed out - the original solution renders the view anyway. Ultimately Richard's suggestion is to remove the etag and to address optimization along these lines separately. So this PR has changed to be removing the etag altogether. |
What is the effect of
Just noting that even if etags are regenerated on every request and render the full page, they still save network bandwidth by returning a |
33fb6b8
to
69cb1f8
Compare
kolibri/core/decorators.py
Outdated
setattr(_response, "response", None) | ||
|
||
request = args[0] | ||
etag = cache.get(request.path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought of one more thing in review:
I don't think it is huge likely, but might be good to prefix the request path with something to prevent accidental cache key collisions if something else is using the path:
So we can add this in the local scope:
CACHE_KEY_TEMPLATE = "SPA_ETAG_CACHE_{}"
Then to generate the cache key:
cache_key = CACHE_KEY_TEMPLATE.format(request.path)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed using the cache key template here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good - have manually tested and confirmed that I get a 304, even if I wait > 15 secs, so the regeneration of the etag is working properly.
Summary
After further discussion with @rtibbles this PR has changed to be removing the etag decorator we were looking at altogether.
-- below this is the original comment --
Updated the etag generation decorator function so that it also uses the rendered HTML which includes everything in
plugin_data
.Is there a better or easier way to get
plugin_data
only?I hate that I call the view_func twice and feel like that could be a problem - I'll come back to it.
Reviewer guidance
kolibri_plugin.py
file for the plugin associated with the URL you're testing. Add a key to theplugin_data
References
#6785
Contributor Checklist
PR process:
Testing:
Reviewer Checklist
yarn
andpip
)