Skip to content
Console

Cache, purge, and prefetch

The first time a file is requested, the CDN fetches it from the origin. After that, the edge cache returns it directly. Cache durations are set by the platform's default policy, and there are currently no settings for custom cache rules. After a file changes, use purge to clear the edge cache. Before a release, use prefetch to pull files to the edge in advance.

Default cache policy

ContentEdge cacheBrowser cache
Web pages (Content-Type starts with text/html)7 days1 day (Cache-Control: public, max-age=86400)
Other files365 days30 days (Cache-Control: public, max-age=2592000)
4045 seconds-

Whether something is a web page is decided by the object's Content-Type, not its extension. An object's own Cache-Control and Expires don't affect the edge duration, and the Cache-Control returned to browsers follows the table above.

ContentEdge cacheBrowser cache
200 and 206 responses, including web pages365 daysAbout 1 year (Cache-Control: public, max-age=31650000)
4045 secondsCache-Control: no-store
Redirects (except 304) and other errorsNot cachedCache-Control: no-store

The Cache-Control and Expires returned by your origin are ignored. Dynamic pages from your origin are also cached for a long time, so connect only static-asset domains to the CDN.

The default policy gets updated. An existing CDN domain uses the latest policy only after you next save any setting and the deployment completes. The policy for some early CDN domains may differ.

Purging doesn't affect browser caches. A file already cached in a visitor's browser updates only when it expires or the file address changes.

How the cache is keyed

Origin typeWhat differences are cached separately
S4 bucket originPath, origin path prefix, media processing parameters, style, response-* parameters, S3 signature parameters, and whether gzip is accepted. When the output format is set to auto, the image format supported by the browser is also part of the key
Custom originPath, all URL parameters (parameter order doesn't matter), and whether gzip is accepted
  • With a bucket origin, custom parameters such as ?v=2 and ?t=123 aren't part of the cache key, so you can't use them to get around an old cache.
  • The _btf_tk and _ts of advanced authentication aren't part of the cache key.

Put a version number or content hash in the file name (such as app.3f9a1c.js) and use a new file name when you update. A new address has no old cache, so you don't need to purge, and browser caches don't matter. Use purge only when you must overwrite a file of the same name.

Purge the cache

Entry point: CDN › Purge cache (刷新缓存) (open), with three tabs: URL purge (URL 刷新), Directory purge (目录刷新), and Prefetch (预热).

URL purgeDirectory purgePrefetch
PurposeClears the edge cache for specified URLsClears the edge cache for a directory and its subdirectoriesPulls files to the edge in advance
Daily quota (per account)5,0001005,000
Per-submission limit1,00020100
Time to take effectAbout 5 minutesAbout 5 minutesDepends on file size and origin speed

Quotas reset every day at 00:00 (Beijing time). The console and the API share the quota, and the page shows the number remaining today.

Submit a URL purge

  1. Open URL purge.
  2. Click the input box and enter one complete URL per line. You can also drag a .txt file in.
  3. Click Submit (提交).

Entry rules:

  • Start with http:// or https://, and include the domain and path
  • You can submit only URLs of running domains in your account. If any one doesn't belong to your account, the whole batch fails
  • Exact to the resource. Regular expressions and wildcards aren't supported
  • URL-encode Chinese characters, spaces, %, and other special characters first
  • An address with media processing parameters is a separate cache entry, so submit the complete URL visitors actually request. When you don't want to list them one by one, use a directory purge

Submit a directory purge

Same as URL purge, but every line must end with /, for example https://cdn.example.com/images/. This clears the directory and all its subdirectories. To purge a whole domain, enter https://cdn.example.com/.

After a directory purge, a large number of requests go to the origin at once, which generates origin fetch traffic and load on your origin. Keep the directory scope as small as possible. Each submission can't exceed the remaining quota for the day.

Check progress

The URL purge records (URL 刷新记录) and Directory purge records (目录刷新记录) below the page show the status of each entry:

StatusMeaning
Purging (刷新中), Prefetching (预热中)In progress
Purge succeeded (刷新成功), Prefetch succeeded (预热成功)Done

Click the refresh icon next to the title to update statuses. Each page shows 10 entries.

Prefetch

Use it before campaigns and version releases to place large files at the edge in advance, so the first visitors don't trigger origin fetches.

  1. Open Prefetch.
  2. Specify operation time (指定操作时间): choose Don't specify (不指定) to run immediately. Choose Specify (指定) and pick a time under Operation time (操作时间), which must be later than now and within 24 hours.
  3. Enter one complete URL per line. The rules are the same as for URL purge.
  4. Click Submit.

Prefetch generates origin fetch traffic. What prefetch pulls is the gzip version of the cache. If the edge already has an old cached copy, purge first, and prefetch after the purge completes.

Messages when submission fails

MessageWhat to do
"今日剩余刷新限额不足" (not enough purge quota left today), "URL刷新余量不足" (not enough URL purge quota), "目录刷新余量不足" (not enough directory purge quota), "缓存预热余量不足" (not enough prefetch quota)Today's quota is used up. Submit again tomorrow.
"单次操作数量不能超过…个" (a single operation can't exceed … entries)Submit in batches.
"第N个 URL 格式有误,请输入完整的 URL" (URL N is malformed, enter a complete URL)Add the protocol and domain, and check special characters.
"第N个 URL 格式有误,必须以 / 结尾" (URL N is malformed, it must end with /)Every line of a directory purge must end with /.
"您当前已欠费,请先充值" (you have an overdue balance, please top up first)Top up and try again.
"发生错误,请稍后重试" (an error occurred, try again later)First confirm each URL's domain belongs to your account, then try again later.

Purge with the API

curl -X POST "https://api.bitiful.com/cdn/cache/refresh" \
  -H "Authorization: <API Token>" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "url",
    "url_list": [
      "https://cdn.example.com/app.js",
      "https://cdn.example.com/style.css"
    ]
  }'

A successful call returns {"message":"ok"}, which means the task was submitted. For parameter details, see the Static CDN API. You can wire it into your release pipeline so it purges automatically after uploads finish.

FAQ

The purge succeeded, but the browser still shows the old file

A purge clears only the edge cache, and the browser still has a local cache. Use an incognito window or curl to confirm the edge has the new content, then force-refresh the browser. The long-term fix is to use versioned file names.

I overwrote a file in the bucket. Do I need to purge?

Yes. Uploading to the bucket doesn't purge the CDN automatically.

I deleted a file from the bucket, but it's still accessible through the CDN

The edge cache is still there. Purge the corresponding URL or directory.

What if I need different cache times by file type?

There's no such setting at the moment. Web pages and other files already have different durations. When you need a shorter cache, use purge.