CDN, or content delivery network — is a system of servers located in different parts of the world. They cache static elements of the site (images, scripts, styles, etc.) so that when a user accesses it, the data is downloaded not from the main server, but from the nearest CDN node. This increases response speed and improves resource performance.
CDN is enabled by default for all site protection services. Controls are available in the general settings, including enabling and disabling caching.
The following formats are cached:
.js, .css, .ejs, .png, .jpg, .jpeg, .gif, .ico, .bpm, .svg, .svgz, .cur, .pict, .tif, .tiff, .eps, .ttf, .eot, .otf, .woff, .woff2, .swf, .mp3, .mp4, .ogg, .wav, .webm, .webp, .avi, .flv, .mov, .pls, .midi, .mid, .mkv, .m4v, .ts, .m3u8, .txt, .exe, .zip, .xz, .gz, .lzma, .7z, .rar, .class, .jar, .tar, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .pdf, .rtf, .csv, .ps, .odt, .ods, .odp, .odg.
Responses from the server are cached if
Authorization
Accept
specifying the type of static content (starts with image
, audio
, video
, text/css
, text/font
), OR request contains a header If-Modified-Since
или If-None-Match
Last-Modified
, Expires
или Cache-Control
Content-Length
and its value does not exceed 2048 megabytesThe HTTP response header ddg-cache-status
indicates whether content is being served from the CDN cache (status HIT
)or from the target server (status MISS
).
The Accept header must match the regular expression ^(image|audio|video|text\/css|font)
HTTP header directives are used to control caching Cache-Control .
The file storage time in the CDN cache depends on the freshness of file, which is set in one of the following ways:
s-maxage
, the freshness period of the file is determined by its value;max-age
.If no direct directives are available, a freshness assessment heuristic is used:
Expires
and Date
(if Date is greater than Expires, freshness is zero);Expires
/Date
— 10% of the difference between Date
and Last-Modified
;Date
/Last-Modified
— 5 minutes.The freshness heuristic always ranges from 5 minutes to 10 days.
A file is revalidated if its lifetime has expired. The default lifetime is freshness, but some directives may affect its formula:
min-fresh
— revalidate when min-fresh seconds remain before the object lifetime expires. Reduces the actual lifetime of the file.max-stale
— gives from cache even within max-stale seconds after freshness expiration. Increases the actual lifetime of the file.