nitro icon indicating copy to clipboard operation
nitro copied to clipboard

asset.maxAge not applied with `fallthrough: true`

Open nksaraf opened this issue 1 year ago • 2 comments

https://github.com/unjs/nitro/blob/b0f08c1c3b1b9e530c0ff9731aba399fd8ada0c3/src/nitro.ts#L85-L95

Looks like when fallthrough: true, a publicAsset's maxAge property is not applied, so no cache-control headers are added.

Is there a way to go around this. I need fallthrough: true because I want to server the /public dir at / base. But imagine i want a route rule too apply to all the public assets at /**, (but not the cases which fallthrough to a lower handlet). Is this not possible right now?

nksaraf avatar Mar 13 '24 01:03 nksaraf

As I can see, it uses defu to apply defaults to provided routeRules. You can still pass in your own routeRules with the required headers. See: https://nitro.unjs.io/guide/routing#route-rules

amandesai01 avatar Mar 13 '24 07:03 amandesai01

please provide a minimal reproduction 🙏🏼

pi0 avatar Mar 13 '24 08:03 pi0

I think the easiest way is to explicitly add routeRules entries for asset path cache headers. (nitro cannot safely assume to apply headers to paths that can fallback to other handlers)

pi0 avatar Nov 08 '24 11:11 pi0