Pages not respecting custom Cache-Control header

Any ideas on why Page's wouldn't be respecting a custom cache-control header for CSS files? I have this in my _headers file:
/*.css
Cache-Control: public, max-age=0, must-revalidate
/*.css
Cache-Control: public, max-age=0, must-revalidate
Yet, CSS files are being served with
Cache-Control: public, max-age=14400, must-revalidate
Cache-Control: public, max-age=14400, must-revalidate
Any ideas?
1 Reply
mulch
mulchOP11mo ago
For context, here's the full content of my _headers file:
/*
# Basic security headers
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff

/*.js
Cache-Control: public, max-age=31536000, immutable

/images/*
Cache-Control: public, max-age=31536000, immutable

/fonts/*
Cache-Control: public, max-age=31536000, immutable

/*.html
Cache-Control: public, max-age=31536000, immutable

/*.css
Cache-Control: public, max-age=0, must-revalidate

/index.html
Cache-Control: no-cache

/*.txt
Cache-Control: no-store
/*
# Basic security headers
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff

/*.js
Cache-Control: public, max-age=31536000, immutable

/images/*
Cache-Control: public, max-age=31536000, immutable

/fonts/*
Cache-Control: public, max-age=31536000, immutable

/*.html
Cache-Control: public, max-age=31536000, immutable

/*.css
Cache-Control: public, max-age=0, must-revalidate

/index.html
Cache-Control: no-cache

/*.txt
Cache-Control: no-store
I can confirm that the _headers file is indeed getting copied over in my builds, so that's not the issue. Ah, just read this:
Custom headers defined in the _headers file are not applied to responses from Functions, even if the Function route matches the URL pattern. If your Pages application uses Functions, you must migrate any behaviors from the _headers file to the Response object in the appropriate /functions route. When altering headers for multiple routes, you may be interested in adding middleware for shared behavior.
Pretty sure that's the issue. That was the issue. Setting these headers via _middleware.js works.
Want results from more Discord servers?
Add your server