imslc cf的缓存配置,是根据你的程序决定的.因为cloudreve它的静态文件很多时候为了持久化和加载速度会将maxage设置得很长.
如果你想让开启网页时从cdn或者服务器去加载你可以通过nginx设置add_header Cache-Control头去修改默认的静态文件缓存值.
参考: https://developers.cloudflare.com/cache/concepts/cache-control/
在cf上你不设置任何规则时,cdn会适应你的程序设置的缓存值,你可以在cdn与程序之间使用nginx来修改.
比方说:
add_header Cache-Control "public, max-age=604800, s-maxage=604800, must-revalidate";
add_header Cloudflare-CDN-Cache-Control "public, max-age=1209600, must-revalidate";
add_header CDN-Cache-Control "public, max-age=1209600, must-revalidate";
这段,clouflare是会以你设置的值去缓存某个文件的.
这段设置意思是浏览器缓存604800,cdn缓存1209600,其中must-revalidate,使用前会向源去校验是否失效.
我通过设置nginx匹配规则来动态修改静态文件的缓存值
# json, xml
location ~* \.(json|xml)$ {
include nginxconfig/cache/header-no-store.conf;
try_files $uri @proxy;
}
# csv
location ~* \.(csv)$ {
include nginxconfig/cache/header-private.conf;
try_files $uri @proxy;
}
# css, js
location ~* \.(?:css(\.map)?|js(\.map)?|ico|wasm)$ {
include nginxconfig/cache/header-must-revalidate.conf;
include nginxconfig/cache/cache.conf;
try_files $uri @proxy;
}
# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
include nginxconfig/cache/header-immutable.conf;
include nginxconfig/cache/cache.conf;
try_files $uri @proxy;
}
# image
location ~* \.(jpe?g|png|gif|cur|bmp|heic|webp|tiff?)$ {
include nginxconfig/cache/header-immutable.conf;
include nginxconfig/cache/cache.conf;
try_files $uri @proxy;
}
# Markdown
location ~* \.md$ {
include nginxconfig/cache/header-must-revalidate.conf;
include nginxconfig/cache/cache.conf;
try_files $uri @proxy;
}
# video
location ~* \.(mp4|mov|avi|wmv|flv|mkv|webm)$ {
include nginxconfig/cache/header-no-transform.conf;
include nginxconfig/cache/cache.conf;
try_files $uri @proxy;
}
# audio
location ~* \.(mp3|wav|ogg|flac|aac)$ {
include nginxconfig/cache/header-no-transform.conf;
include nginxconfig/cache/cache.conf;
try_files $uri @proxy;
}
这只是示例,你需要自行去理解.
据我所知cf,cloudfront,cachefly这些cdn都会根据源站的add_header Cache-Control去配置缓存,除非你在cdn中有自己的规则.
你的目的是加载质询页面,但是程序其实已经加载到了本地,它没有向cdn请求就不会触发质询,你可以尝试将缓存值设置得很低,通过上面的文档你可以看到,你有办法让cdn缓存但是不让客户端缓存.值低了过后,它势必会去向cdn请求,那你就可以看到质询界面了.还有一种就是你在cdn中设置的质询失效时间例如4小时,你可以让客户端缓存4小时,刚好匹配质询的时间.
如果还是有问题,那就可以看看官方demo,控制台看它的响应头,它设置了什么值.
最重要的是免费的cf,我的质询是从来没有弹出过.只有在2年前有,现在官方好像把这个功能弱化了,为了让你开pro.