lisaogren / axios-cache-adapter

Caching adapter for axios. Store request results in a configurable store to prevent unneeded network requests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It is not caching post requests

robertovaldesperez opened this issue · comments

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