-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
[Bug] Cache is not deleted on memoryStorage #437
Comments
For now I am adding |
The The whole axios & cache workflow is correctly evicting your cache entry, but your browser is doing another cache barrier, because we, as the javascript code, works within the js scenary, and the browser may be up to be also handling cache in their side, so js does not have any control. The right way seems to be using the following headers in the {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': '0',
} This way the browser ignores cache and just axios handles them for you. See this StackOverflow post. Don't worry this will be a request header, so it won't mess up with any future request cache. It is also not a bug, because every time that the browser should work as a middleware and be able to return But I'm 100% sure that this edge case, as it only happens on browsers, needs a space in the documentation, you're up to a PR? |
Hey @infel, I actually took a time to thing about this problem and decided to fix in internally by adding |
I just read your reply just now, thank you for taking some time to explain things and adding |
Describe the bug
I am caching a get request with an id of
blog-posts
on a vue 2 app. Then I am trying to deleteblog-posts
entry onmemoryStorage
by addingcache.update
to my post request whenever create, update or delete requests are called to blog API.Logging
axios.storage
after each request (create, update or delete) shows thatblog-posts
no longer exists. But when I navigate on the blog index page, request toblog-posts
returns old data, weird thing is thatresponse.cache
showsfalse
. On the chrome devtools Network tab, I see that the request is loaded fromdisk cache
. Can confirm thataxios.storage
has the old data, does this mean that theblog-posts
key was never deleted from memoryStorage?I even tried doing
delete window.memoryStorage.data[response.id]
but to no avail.Also nginx is returning
cache-control: max-age=172800
header on the response, don't know if that's related. But I havewindow.axios.defaults.cache.interpretHeader = false
so it should not be the case right?To Reproduce
Expected behavior
blog-posts
entry in memoryStorage should have been deleted and request should not use response fromdisk cache
Additional context
v2.7.8
v1.2.1
v0.10.7
Memory Storage
v14.0.0
Version 107.0.5304.110 (Official Build) (x86_64)
The text was updated successfully, but these errors were encountered: