{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/21","labels_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/21/comments","events_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/21/events","html_url":"https://github.com/GoogleChrome/sw-toolbox/issues/21","id":95557271,"number":21,"title":"Returning cached resource based on route without considering method","user":{"login":"zmoshansky","id":3180807,"avatar_url":"https://avatars.githubusercontent.com/u/3180807?v=3","gravatar_id":"","url":"https://api.github.com/users/zmoshansky","html_url":"https://github.com/zmoshansky","followers_url":"https://api.github.com/users/zmoshansky/followers","following_url":"https://api.github.com/users/zmoshansky/following{/other_user}","gists_url":"https://api.github.com/users/zmoshansky/gists{/gist_id}","starred_url":"https://api.github.com/users/zmoshansky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zmoshansky/subscriptions","organizations_url":"https://api.github.com/users/zmoshansky/orgs","repos_url":"https://api.github.com/users/zmoshansky/repos","events_url":"https://api.github.com/users/zmoshansky/events{/privacy}","received_events_url":"https://api.github.com/users/zmoshansky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-17T00:14:55Z","updated_at":"2015-07-30T15:30:53Z","closed_at":null,"body":"I'm using sw-toolbox through Polymer's `platinum-sw-cache` and `iron-ajax` and it's come up with a bit of strange behaviour explained below:\r\n```\r\nGET /api/resource --> 200 {\"data\": [{\"id\": 1}, {\"id\":2}]\r\nPOST /api/resource --> Server sends 422 {\"errors\": [{\"description\": \"can't be blank\"}]}, SW intercepts and returns 200 {\"data\": [{\"id\": 1}, {\"id\":2}] `Status Code:200 OK (from ServiceWorker)`\r\n```\r\nHowever, When inspecting the service worker, it shows 2 Requests:\r\n```\r\nRequest Method:OPTIONS\r\nStatus Code:200 OK\r\n```\r\n```\r\nRequest Method:POST\r\nStatus Code:422 Unprocessable Entity\r\n```\r\nand `POST https://localhost:4000/api/resource 422 (Unprocessable Entity)` in the console\r\n\r\nTBH, I don't really expect anything but GET to be cached, which may the case, but it definitely shouldn't replace my POST's 422 and body with a 200 OK and the GET body."},"comment":{"url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/comments/126371267","html_url":"https://github.com/GoogleChrome/sw-toolbox/issues/21#issuecomment-126371267","issue_url":"https://api.github.com/repos/GoogleChrome/sw-toolbox/issues/21","id":126371267,"user":{"login":"wibblymat","id":393358,"avatar_url":"https://avatars.githubusercontent.com/u/393358?v=3","gravatar_id":"","url":"https://api.github.com/users/wibblymat","html_url":"https://github.com/wibblymat","followers_url":"https://api.github.com/users/wibblymat/followers","following_url":"https://api.github.com/users/wibblymat/following{/other_user}","gists_url":"https://api.github.com/users/wibblymat/gists{/gist_id}","starred_url":"https://api.github.com/users/wibblymat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wibblymat/subscriptions","organizations_url":"https://api.github.com/users/wibblymat/orgs","repos_url":"https://api.github.com/users/wibblymat/repos","events_url":"https://api.github.com/users/wibblymat/events{/privacy}","received_events_url":"https://api.github.com/users/wibblymat/received_events","type":"User","site_admin":false},"created_at":"2015-07-30T15:30:53Z","updated_at":"2015-07-30T15:30:53Z","body":"Hi @zmoshansky, I'm sorry I didn't see your issue earlier - apparently I unwatched the repo by mistake :/\r\n\r\nYes, this is a silly mistake on my part - the Response type should match the Request type. We already only cache GET requests, so I'll need to put a similar check around fetching from the cache.\r\n\r\nThanks for reporting!"}}