-
Notifications
You must be signed in to change notification settings - Fork 9
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
Standardise cache time for all assets #523
Conversation
a679333
to
5e9ee6f
Compare
Can you review this when you have a minute please, @chrislo. |
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.
Looks good to me @chrisroos.
For future reference for the "Set Cache-Control to no-cache in the API show action" commit I think this answer on SO explains the reason why no-cache
and max-age=0
are practically equivalent.
This removes one of the differences in behaviour between Whitehall and mainstream assets. We're about to start serving in the region of an additional 500,000 assets from Asset Manager and so we've standardised on 24 hours (instead of 4 hours) in order to reduce the frequency at which caches have to check for freshness. We've added some notes to #518 to give an idea of the number of requests we might expect to serve.
We can remove this duplication now that we've standardised on a 24 hour cache.
There's no longer any difference between the implementation in `MediaController` and `WhitehallMediaController` so we can remove some duplication by pulling the `cache_control` method up to the parent class.
There's no difference between the implementation in `BaseAssetsController` and `BaseMediaController` so we can remove some duplication by pulling the `cache_control` method up to the parent class.
Now that it's only used in `ApplicationController#cache_control`.
To remove some duplication from the `MediaController` and `WhitehallMediaController`.
We think this makes the intention clearer by explicitly preventing the response from being cached. Note that in practice we don't think there's any difference between the two implementations. Our motivation is to simplify and hopefully remove the `CacheControlConfiguration` class.
Removing this custom use of the `cache_control` method will allow us to simplify it and ultimately remove the `CacheControlConfiguration` class. I think there's probably a bit of an open question about how sensible it is to cache the redirect for a minute.
Now that it's only being used by `ApplicationController#set_default_expiry`.
Now that it's only used by `ApplicationController#set_default_expiry`.
We can simplify the code now that we're only ever using the `CacheControlConfiguration` class to set the cache expiry to 24 hours.
This was made redundant in the previous commit (titled "Avoid using CacheControlConfiguration")
a590531
to
b6c9ffb
Compare
Thanks for reviewing, @chrislo. I've rebased on master in preparation for merging. |
This addresses issue #518 by standardising on a 24 hour cache for both mainstream and Whitehall assets.
I've removed the
CacheControlConfiguration
class as it feels like overkill now that we're not using the flexibility it provides.