swup / swup

Versatile and extensible page transition library for server-rendered websites 🎉

Home Page:https://swup.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow bypassing cache for load and save

daun opened this issue · comments

Describe the problem

There should be a way of disabling the cache to help with forms, especially on POST requests.

  1. Bypass cache on load: ignore any previously cached pages
  2. Skip cache on save: do not store the response in the cache

Describe the proposed solution

  1. Extend FetchOptions with two parameters, e.g.
    a. bypassCache and skipCacheSave with default false
    b. getFromCache and saveToCache with default true
  2. Extend FetchOptions with a cacheControl parameter that mimics the Cache-Control header
  3. Directly read from the request headers and interpret the Cache-Control header ourselves

Alternatives considered

  • Manually clearing the cache before a request
  • Manually clearing the cache after a request

How important is this feature to you?

  • Nice to have
  • Would make my life a lot easier
  • I cannot use swup without it

I'd vote for 1b, to keep it simple

I've switched the proposed feature to a slightly different API that works well with the visit object:

cache: boolean | { read: boolean, write: boolean }