Coder Social home page Coder Social logo

Turn off cache? about render HOT 4 CLOSED

kotx avatar kotx commented on June 22, 2024
Turn off cache?

from render.

Comments (4)

kotx avatar kotx commented on June 22, 2024

a), in wrangler.toml:

# The `cache-control` header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control.
# Optional, the `cache-control` header is omitted if unset, which would NOT disable caching: https://developers.cloudflare.com/workers/runtime-apis/cache/#headers
# For example, you can disable all cache by setting this to `no-store`.
CACHE_CONTROL = "max-age=86400"

So just set it like CACHE_CONTROL = "no-store"

b)
You can manually invalidate the cache by going to the Cloudflare dashboard and purging the cache for URL(s) in a zone like so:
image

from render.

davej avatar davej commented on June 22, 2024

@kotx thanks! I think (b) is for the Cloudflare CDN cache and not the worker’s internal cache.

from render.

kotx avatar kotx commented on June 22, 2024

@kotx thanks! I think (b) is for the Cloudflare CDN cache and not the worker’s internal cache.

Are you sure the cache is not shared? The Cache API that the worker uses should allow at least purging by tag, host, or prefix. Purging by URL should also work, but I'm not sure on the wording. Take a look at the documentation for details.

from render.

davej avatar davej commented on June 22, 2024

I'm not sure at all, to be honest, the docs suggested to me that they were different. If they are the same cache then they could probably be deleted programmatically using the Cloudflare API. Something like this:

await fetch(
  "https://api.cloudflare.com/client/v4/zones/aa7f1c06205063c0a3b298060d716e7f/purge_cache",
  {
    body: JSON.stringify({
      files: [pathToDelete],
    }),
    headers: {
      "Content-Type": "application/json",
      // auth headers
    },
    method: "POST",
  }
);

from render.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.