[ServiceWorker] Replaying POST requests (#693)

Let's consider offline-first survey application.

When users performs some /GET requests SW will respond with cached content
But when users performs /POST request situation get's complicated. I want to:

1. Perform request by application
1. Fetch the request by SW
1. SW to check if it can send that request to the server
1. If yes - respond with 200 to application 
1. If not - cache the request (store in IDB / cache) and retry it later (ex. using Background Sync)

How in your opinion replaying requests should be performed?  I would like ServiceWorker to be a [programmable network proxy](http://www.html5rocks.com/en/tutorials/service-worker/introduction/), so I would like ServiceWorker to handle whole process - application should just send one request and don't care anymore. But sending a POST request is meant to change something on server - we have to make user (application) aware of the fact that it was failed but successfully cached.

[Jeff's response](http://stackoverflow.com/questions/30046374/how-can-we-check-if-response-for-the-request-came-from-service-worker) to this issue is OK, but he also suggests that application should be responsible for replaying the requests - and I believe it'd be better to separate these layers (for Background Sync). 


---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/693

Received on Thursday, 7 May 2015 08:12:56 UTC