You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
Apps often make requests like "/api/users?_dc=123456789", where _dc is the timestamp at which the request is generated and is used to prevent caching. This always results in a cache miss when using sw-toolbox. When it is desirable to fetch fresh data from the server when connected to the network, but fall back on the last cached response when offline, it would be great if there was a way read from the cache for /api/users when /api/users?_dc=123456789 fails to connect.
The sw-precache library already contains a similar option called ignoreUrlParametersMatching. Building on that, one could imagine the following:
Hey Mark, that would be an awesome pull-request. I did a quick look through the codebase, and it looks like the place where the query strings are being ignored is in /lib/router.js on line 98. Where it says var path = urlObject.pathname. For example, to always treat query strings as their own unique requests you would modify this line to read: var path = urlObject.pathname + urlObject.search. Hopefully this helps get you started.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Apps often make requests like "/api/users?_dc=123456789", where _dc is the timestamp at which the request is generated and is used to prevent caching. This always results in a cache miss when using sw-toolbox. When it is desirable to fetch fresh data from the server when connected to the network, but fall back on the last cached response when offline, it would be great if there was a way read from the cache for /api/users when /api/users?_dc=123456789 fails to connect.
The sw-precache library already contains a similar option called ignoreUrlParametersMatching. Building on that, one could imagine the following:
toolbox.router.get(/api\/users/, toolbox.networkFirst, { ignoreUrlParametersMatching: /^_dc$/ })
The text was updated successfully, but these errors were encountered: