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

ToolbarMiddleware interferes with WhiteNoise Cache-Control header #6608

Open
bhrutledge opened this issue Feb 4, 2019 · 0 comments
Open

Comments

@bhrutledge
Copy link

Summary

I'm switching an app from hosting static files on S3 to serving them from Django via WhiteNoise, behind the CloudFront CDN. WhiteNoise uses a middleware to intercept requests to STATIC_URL, and returns a file response. This is all relatively straightforward to set up.

Expected behaviour

  • Hashed static files served via WhiteNoise should have a far-future Cache-Control header
  • More broadly, Django CMS shouldn't set a "never cache" header for responses that don't include a toolbar

Actual behaviour

During testing I discovered that the Cache-Control header was still being set to "never cache" for static files. A dive through PDB led me to the ToolbarMiddleware and the behavior of using the cache-disabled EmptyToolbar while processing the response for non-CMS pages.

One possible workaround is to set CMS_TOOLBAR_HIDE = True, which short-circuits ToolbarMiddleware processing. However, this causes problems for us because we have views that have toolbar-related functionality, but aren't CMS pages. As a workaround for that, I subclassed ToolbarMiddleware to override is_cms_request to recognize the additional views.

Environment

  • Python version: 2.7.15
  • Django version: 1.11.18
  • django CMS version: 3.4.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants