Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

It is not caching post requests #240

Open
robertovaldesperez opened this issue Mar 10, 2021 · 0 comments
Open

It is not caching post requests #240

robertovaldesperez opened this issue Mar 10, 2021 · 0 comments

Comments

@robertovaldesperez
Copy link

robertovaldesperez commented Mar 10, 2021

function configure() {
  localforage.defineDriver(memoryDriver)

  const forageStore = localforage.createInstance({
    driver: [
      localforage.INDEXEDDB,
      localforage.LOCALSTORAGE,
      memoryDriver._driver
    ],
    name: 'guru-cache'
  })

  return setup({
    baseURL: process.env.VUE_APP_BASE_API,
    timeout: 0,

    cache: {
      maxAge: 15 * 60 * 1000,
      store: forageStore,
      key: (req) => {
        return req.url + (req.data ? serializeQuery(req.data) : '')
      },
      exclude: {
        query: false,
        filter: (req) => {
          return !req.readonly
        },
        methods: ['patch', 'put', 'delete']
      },
      invalidate: async(cfg, req) => {
        if (!req.readonly) {
          await cfg.store.removeItem(cfg.uuid)
        }
      }
    }
  })
}

it is only caching get requests
image

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

No branches or pull requests

1 participant