-
Notifications
You must be signed in to change notification settings - Fork 20
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
Client side caching may be overriding cache invalidation #67
Comments
An idea I'm playing with is to adjust the
The biggest problem here is that A second option would be to change |
@peterbe thoughts on the See https://docs.djangoproject.com/en/4.0/topics/conditional-view-processing/ for discussion of the Etag header. |
No, I don't think this library should make such connections. Client-side caching is very different from server-side caching. It's not inconceivable that you want the server to cache but the client to not cache it. Pardon my ignorance, but aren't the from fancy_cache import cache_page
from django.views.decorators.cache import never_cache
@never_cache
@cache_page(60 * 60)
def myview(request):
return render(request, 'page1.html') That would force the client to keep coming back for the latest and freshest but at the same time the server would be able to process that request fast since it's cached. |
@peterbe makes sense - and this is exactly what I'm currently doing everywhere I'm using fancy cache's cache_page decorator. What I was considering was whether A/ many users would want this functionality built-in with a setting, which makes sure they don't forget to add the never_cache decorator, or B/ whether it would be possible to use an etag function that would further improve response times from the API, in that the cached response wouldn't need to be sent if the entry in the fancy_urls dict were found with the same etag value. This seems like a small optimization though so I'm going to close this. |
@peterbe reopening because I just realized that the latest version of our middleware, which follows the Django cache middleware, does not cache the response if the the
...and this would also add the never_cache headers elsewhere in the middleware so I don't need to make my special version of
None of this is absolutely necessary but thought to put this here in case anyone else encounters the issue in the future. |
I haven't been able to fully research this as it's quite complex and I'm not an expert on caching headers, but plan to in the future and want to write it down to make sure I'm not on a completely wrong path.
What I'm experiencing is that browsers that are accessing pages that are cached and invalidated using django-fancy-cache are still pulling a resource
(from disk cache)
on chrome. Hard refresh of the browser solves the issue which makes me believe this is an issue with browser caching results to disk.Question - should items cached and invalided by fancy-cache include a
no-cache; no-store
header? Otherwise is there a good way to make sure that the browser doesn't pull a stale response from its local cache?I've looked into
Etag
and I suspect that might be a good alternative; as far as I can tell this would allow cache invalidation based on the hashed value of the response.The text was updated successfully, but these errors were encountered: