Closed Bug 1340310 Opened 8 years ago Closed 6 years ago

How does the Cache interface handle cookies?

Categories

(Developer Documentation Graveyard :: JavaScript, defect, P1)

All
Other
defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: ddascalescu+github, Assigned: cmills)

References

()

Details

:: Developer Documentation Request Request Type: New Documentation Gecko Version: unspecified Technical Contact: ARRAY(0x7f2c4a267c70) :: Details Please see this StackOverflow question - http://stackoverflow.com/questions/42285758/how-does-service-worker-handle-cookies > How are cookies proxied when pages are served from SW caches? If I invalidate a cookie or change its value outside of the page and then try to read it from JavaScript inside the page, will I get the old value or the new value? > If there was a Set-Cookie: header in the response, will that get stored in the cache? Will that header be replayed and go into effect each time the response was read from cache?
I actually have no idea how this would work - it's a really good question. Jake/Alex? ;-)
Assignee: nobody → cmills
Hi Ben, Would you be able to give us an answer to this question? Thanks in advance.
Assignee: cmills → nobody
Flags: needinfo?(bkelly)
I believe the fetch spec requires stripping set-cookie headers before returning a Response object from fetch(). So storing a Response in Cache API should never contain headers. Writing a demo in glitch or something would be the easiest way to tell if this is properly implemented. Unfortunately I don't have time to do this at the moment, though.
Flags: needinfo?(bkelly)
Assignee: nobody → cmills
I have added a small bit of information about this to MDN here: https://developer.mozilla.org/en-US/docs/Web/API/Cache#Storing_cookies_in_Caches I am not really suer if that answers the question sufficiently, so I'd appreciate some more help. I did try setting up a service worker example that sets a cookie and then Caches the JS page doing the setting inside a SW. When you get it registered and then active, then turn off the wifi network, then reload, the SW works, but the cookie does not seem to be set.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.