Skip to content
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

Merged
merged 12 commits into from
Mar 28, 2018

Conversation

chrisroos
Copy link
Contributor

@chrisroos chrisroos commented Mar 14, 2018

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.

@chrisroos chrisroos force-pushed the standardise-cache-time-for-all-assets branch from a679333 to 5e9ee6f Compare March 28, 2018 11:27
@chrisroos chrisroos changed the title WIP: Standardise cache time for all assets Standardise cache time for all assets Mar 28, 2018
@chrisroos chrisroos requested a review from chrislo March 28, 2018 11:34
@chrisroos
Copy link
Contributor Author

Can you review this when you have a minute please, @chrislo.

@chrislo chrislo self-assigned this Mar 28, 2018
Copy link
Contributor

@chrislo chrislo left a 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")
@chrisroos chrisroos force-pushed the standardise-cache-time-for-all-assets branch from a590531 to b6c9ffb Compare March 28, 2018 16:27
@chrisroos
Copy link
Contributor Author

Thanks for reviewing, @chrislo.

I've rebased on master in preparation for merging.

@chrisroos chrisroos merged commit e0ddbe7 into master Mar 28, 2018
@chrisroos chrisroos deleted the standardise-cache-time-for-all-assets branch March 28, 2018 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants