Open kumar303 opened 4 years ago
While I am not sure we want to open the can of worms that is server-side caching yet...There might be endpoints we can serve with a Cache-Control
header, to let clients cache the response for themselves ? The browse endpoint seems like a good candidate, besides the add-on properties I don't think anything can change after it has been loaded.
That being said, we could also make If-None-Match
/If-Modified-Since
requests faster by looking at the modified
date of the version/file object, or something from the git backend.
Yeah, in this case the browser has a cached response and is sending a valid etag in the request. The server agrees and responds with a 304. Is the problem that the API has to create a real response before it can figure out if the etag is valid or not?
Yeah, the default implementation is to generate ETag based on the response (it's a simple hash of the response body), and that's what we use for this API. We could be smarter about this. Returning a Cache-Control
would also sidestep this issue as the browser wouldn't send a request for the duration of the max-age
.
Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDSRV-24
Describe the problem and steps to reproduce it:
What happened?
When refreshing the page, the browser loads a cached version of the response (
/api/v5/reviewers/addon/616959/versions/1688394/
) as indicated in the Network panel. However, the cached response takes the same amount of time as the non-cached one.What did you expect to happen?
The cached response should be faster :rocket:
Anything else we should know?
This is probably similar to https://github.com/mozilla/addons/issues/7100 where the server still calculates the response even when cached.
Example of when the browser makes a cached request:
┆Issue is synchronized with this Jira Task