Skip to content
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

How to avoid caching API requests at all? #46

Closed
bruncanepa opened this issue May 7, 2020 · 1 comment
Closed

How to avoid caching API requests at all? #46

bruncanepa opened this issue May 7, 2020 · 1 comment

Comments

@bruncanepa
Copy link

What config should I set to avoid caching XHR api requests
I managed to doing this, so it is cached for 1 second

runtimeCaching: [
      {
        urlPattern: /\/api\//g,
        handler: 'NetworkFirst',
        options: {
          cacheName: 'api',
          expiration: {
            maxEntries: 1,
            maxAgeSeconds: 1 
          }
        }
      }
    ],
@shadowwalker
Copy link
Owner

I assume this is partial of your runtimeCaching, it will work. But there is some misunderstanding about this configuration. To help you understand it, what it does is whenever a http request send to api route:

  1. If device have network access, it always fetch from network without using any cache
  2. If device doesn't have network access and has cache for api route, it fetch from the cache, but if the cache is expired (1 second after stored) it will return error since the cache is invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants