keymanapp / downloads.keyman.com

Resources for downloads.keyman.com
MIT License
0 stars 1 forks source link

fix: move cache rules from Cloudflare to backend #46

Closed mcdurdin closed 1 year ago

mcdurdin commented 1 year ago

Fixes #42.

We have more control of caching rules by putting them on the backend server instead of in Cloudflare page rules. The specific rule we needed was to never-cache 404 responses:

Header always set Cache-Control no-cache "expr=%{REQUEST_STATUS} == 404"

I have disabled all the corresponding Cloudflare page rules except for the /api/ 30-minute edge cache rule, which I will leave enabled for now (we may consider moving this in a future update).

Once we have verified that this is stable, and that caching is still at an appropriate level, I will delete the disabled Cloudflare page rules.

Note that the Cloudflare transform rule for keyman-setup*.exe is still in place so we continue to benefit from the edge cache here (because setup.exe is cached, but not every variation based on keyboard package name). If this Cloudflare rule is disabled, then we fall back to the corresponding .htaccess rule, but we lose the effective caching.

mcdurdin commented 1 year ago

Note, even with Cache-Control headers, it turns out that we need a cache rule for our special file extensions:

(http.request.uri matches ".(msi|pdb|download_info|kmp|ipa|keyboard_info|model_info)$" and http.host eq "downloads.keyman.com")
mcdurdin commented 1 year ago

It looks like we also need a Page Rule (or Cache Rule) on Cloudflare to explicitly override caching for /data/*.zip.