You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to cache static assets using Varnish Cache as a proxy layer (deployed to fly.io), but currently it seems that due to the nature of Fresh (2.0.0-alpha.25), assets to be marked at runtime using asset/assetSrcSet from fresh/runtime. Varnish doesn't seem to be able to cache such assets. What could be wrong?
Also, is there a plan to get rid of the fresh/runtime entirely to reduce the js bundle, as we already have a prebuild step for files in outdir at /_fresh, but no file hashes for now?
vcl 4.1;
subvcl_recv {
// ...// Mark static files with the X-Static-File header, and remove any cookiesif (req.url ~ "^[^?]*\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|ogg|ogm|opus|otf|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\?.*)?$") {
setreq.http.X-Static-File = "true";
unsetreq.http.Cookie;
return (hash);
}
return (hash);
}
// ...subvcl_backend_response {
// ...// If the file is marked as static and no custom Cache-Control max-age specified, cache it for 1 yearif (bereq.http.X-Static-File == "true" && !beresp.http.Cache-Control) {
unsetberesp.http.Set-Cookie;
setberesp.http.Cache-Control = "public, max-age=31536000, immutable";
setberesp.ttl = 1y;
}
return (deliver);
}
subvcl_deliver {
// Check if the object has been served from cache (HIT) or fetched from the backend (MISS)if (obj.hits > 0) {
// For cached objects with a TTL of 0 seconds but still in grace mode, mark as STALEif (obj.ttl <= 0s && obj.grace > 0s) {
setresp.http.X-Cache = "STALE";
} else {
// For regular cached objects, mark as HITsetresp.http.X-Cache = "HIT";
}
} else {
// For uncached objects, mark as MISSsetresp.http.X-Cache = "MISS";
}
// Set the X-Cache-Hits header to show the number of times the object has been served from cachesetresp.http.X-Cache-Hits = obj.hits;
}
The text was updated successfully, but these errors were encountered:
And for some unknown reason, some HTML pages got caching working properly, while others have identical headers (also cache control) but always have Age: 0. Using the same Varnish configuration for all projects on Node.js - never seen such an error. 🤔
I want to cache static assets using Varnish Cache as a proxy layer (deployed to fly.io), but currently it seems that due to the nature of Fresh (2.0.0-alpha.25), assets to be marked at runtime using
asset/assetSrcSet
fromfresh/runtime
. Varnish doesn't seem to be able to cache such assets. What could be wrong?Also, is there a plan to get rid of the
fresh/runtime
entirely to reduce the js bundle, as we already have a prebuild step for files in outdir at/_fresh
, but no file hashes for now?Dockerfile
:supervisord.conf
:default.vcl
:The text was updated successfully, but these errors were encountered: