hapijs / hapijs/inert

Disabling `must-revalidate` when serving static files via Inert

Open
#163 1 comment 0 reactions 0 assignees View on GitHub
support
Dominant language
JavaScript
Stars
236
Forks
48
PR merge metrics
No merged PRs in 30d

Description

#### Support plan

* *is this issue currently blocking your project?* (yes/no): no
* *is this issue affecting a production system?* (yes/no): no

#### Context

* *node version*: 16.14.2
* *module version*: 6.0.5
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): hapi application
* *any other relevant information*: N/A

#### How can we help?

I'd like to implement a cache-busting mechanism based on filepath, meaning that I'd like to have the `cache-control` header be (exclusively) `max-age={MAX_AGE}, immutable`

However, I can't find a way to not have Inert (or HAPI?) adds the `must-revalidate` directive to this header (or to add `immutable` to it fwiw).

The way we're configuring our route:

```ts
server.route({
path,
method: 'GET',
handler: {
directory: {
path: dirPath,
listing: false,
lookupCompressed: true,
etagMethod : false,
},
},
options: {
auth: false,
cache: {
privacy: 'default',
otherwise: 'immutable',
expiresIn: 365 * 24 * 60 * 60 * 1000,
},
},
});
```

When calling the endpoint, the `must-revalidate` is added

```
Expected: "max-age=31536000, immutable"
Received: "max-age=31536000, must-revalidate"
```

Is there any way to prevent inert from adding the `must-revalidate` directive when serving the files, and to add custom directives (e.g `immutable`)?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.