Django 上游缓存(随标头变化)不起作用
我有一个显示特定于用户的视图,这意味着每个经过身份验证的用户对同一 URL 的响应内容是唯一的。
理想情况下,这些页面将缓存在浏览器中。然而,Chrome 或 Firefox(在生产环境或本地)中似乎并非如此。
尽管我已经设置了 @vary_on_cookies 装饰器,但开发服务器每次都会处理视图。
我有正确的中间件(按正确的顺序):
django.middleware.cache.UpdateCacheMiddleware
django.middleware.cache.FetchFromCacheMiddleware
我需要设置 CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False 吗?
我注意到的一件事是请求正在发送此缓存控制标头:
Cache-Control:max-age=0
我认为这可能是根本问题。或者这与开发服务器有关?
有什么建议吗?
I have a view which displays user specific, meaning the content of the response for the same URL is unique per individual authenticated user.
Ideally, these pages would be cached in the browser. However, that does not appear to be the case in Chrome or Firefox (on production or locally).
The development server is processing the view each time, despite the fact that I've set the @vary_on_cookies decorator.
I have the right middleware in place (in the right order):
django.middleware.cache.UpdateCacheMiddleware
django.middleware.cache.FetchFromCacheMiddleware
Do I need to set CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False?
One thing that I've noticed is that the request is sending this cache control header:
Cache-Control:max-age=0
I assume that that might be the root problem. Or is this related to the development server?
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论