Skip to content

hapi pre-response handler to include Accept in the Vary header

License

Notifications You must be signed in to change notification settings

travi/hapi-vary-accept

Repository files navigation

hapi-vary-accept

hapi pre-response handler to include Accept in the Vary header

Node CI Workflow Status Codecov SLSA Level 2

Table of Contents

Motivation

Google Chrome caches only the last response for any endpoint, regardless of content-type, which results in rendering json data instead of the rendered page based on the html representation. These values are cached even with the Cache-Control header set to no-cache in order to optimize operations like navigating back or duplicating a tab.

While normally unnecessary because of configuring the headers to prevent caching,including Accept in the Vary header does technically further inform a client that a single endpoint responds with different responses based on the Accept header of the request.

Usage

npm MIT license

Installation

⚠️ This plugin does not yet support hapi v17

$ npm install hapi-vary-accept --save

Contribution

Conventional Commits Commitizen friendly Renovate semantic-release: angular

Verification

$ npm test