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

Use cache_control decorator instead of cache_page #652

Merged
merged 2 commits into from
Sep 26, 2014

Conversation

kaedroho
Copy link
Contributor

I used cache_page originally as it sets all the relevant HTTP headers
("Cache-Control" and "Expires") to ask browsers/proxies to cache the
generated image to reduce load.

What I didn't know at the time is that cache_page also inserts the
generated images into the cache backend. Sites with many images being
served thorugh the "Frontend URLs" mechanism could end up with their
cache servers being overloaded.

This pull request replaces the use of cache_page with cache_control
which doesn't insert the image into the cache.

Also, cache_control only sets the "Cache-Control" HTTP header (and not
"Expires"). As "Cache-Control" is defined in the HTTP 1.1 spec, I think
it's safe to assume that the vast majority of browsers and proxies
support it.

I used cache_page originally as it sets all the relevant HTTP headers
("Cache-Control" and "Expires") to ask browsers/proxys to cache the
generated image to reduce load.

What I didn't know at the time is that cache_page also inserts the
generated images into the cache backend. Sites with many images being
served thorugh the "Frontend URLs" mechanism could end up with their
cache servers being overloaded.

This pull request replaces the use of cache_page with cache_control
which doesn't insert the image into the cache.

Also, cache_control only sets the "Cache-Control" HTTP header (and not
"Expires"). As "Cache-Control" is defined in the HTTP 1.1 spec, I think
it's safe to assume that the vast majority of browsers and proxys
support it.
@kaedroho kaedroho added this to the 0.7 milestone Sep 26, 2014
gasman added a commit that referenced this pull request Sep 26, 2014
Use cache_control decorator instead of cache_page
@gasman gasman merged commit 6bc37bf into wagtail:master Sep 26, 2014
gasman added a commit that referenced this pull request Sep 26, 2014
gasman added a commit that referenced this pull request Sep 26, 2014
@kaedroho kaedroho deleted the image-frontend-cache-fix branch September 11, 2015 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants