Wood Chen

What cf-cache-status: DYNAMIC Means: 5 Cloudflare Cache Statuses Explained

0 comments474 views349 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

As a globally renowned CDN provider, Cloudflare (CF for short) hosts countless websites. By default, CF caches common small files such as images, js, and css, but media files such as audio and video are not cached. Open the F12 developer tools and click the file you want to cache. In Headers, you will find cf-cache-status, which indicates the file's current CF cache status. Common statuses include:

  • cf-cache-status:HIT: Your file was found in the CF cache. This means users retrieve it from CF's cache servers rather than your origin server, without consuming your server resources.
  • cf-cache-status:MISS: CF looked for the requested file on its cache servers but did not find it. CF will fetch the file from your origin server, and the next request will show HIT.
  • cf-cache-status: BYPASS: CF has been instructed not to cache this file. Users will retrieve it directly from the origin server. This is usually because the requested file returns a NO-Cache header.
  • cf-cache-status:EXPIRED: The cached file has expired since it was last cached. CF will fetch it from the origin server again, and the next request will show HIT.
  • cf-cache-status:DYNAMIC: This file is not cached by default, and no matching cache rule is configured. Users will retrieve it from the origin server.

Once you understand CF's 5 cache statuses, handling them is straightforward. When your file shows cf-cache-status: DYNAMIC, you just need to configure your page rules in CF. For example, to cache mp4 files, I can set up a page rule like this: https://你的域名/.mp4,

cache level; cache standard (standard caching)

Or cache all files in a specific directory:

https://你的域名/需要缓存的目录/*
cache level:cache everything

This will allow files on your website no larger than 200m to be cached. The * after MP4 is there because wordpress sometimes adds parameters when requesting mp4 files.

PS: The free version of cloud flare only supports 3 page rules. If you need more, you can purchase a paid plan.

Original source:https://2demo.top/77.html

Last updated 2024-01-14

Related posts

Comments 0