Skip to content

Commit

Permalink
[optimizer] allow http caching for bundles (elastic#15880)
Browse files Browse the repository at this point in the history
By setting cache-control to must-revalidate, we indicate to the browser
that it should send the if-none-match header with the last known etag
value. If the etags match, the server responds with a 304 and no body,
and if they don't the server responds with a 200 and a body along with a
new etag.

This ensures a cache is always invalidated when a bundle changes, like
when Kibana is upgraded or a plugin is installed.

We no longer send the last-modified header because we don't want the
browser caching based on time. Doing so can be unpredictable since the
browser may not agree with the server's definitions of DST, and the
server time itself can be changed.
  • Loading branch information
epixa committed Jan 9, 2018
1 parent 3cd90d8 commit 077f9dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/optimize/bundles_route/dynamic_asset_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function createDynamicAssetResponse(options) {
const response = request.generateResponse(replacePlaceholder(read, publicPath));
response.code(200);
response.etag(`${hash}-${publicPath}`);
response.header('last-modified', stat.mtime.toUTCString());
response.header('cache-control', 'must-revalidate');
response.type(request.server.mime.path(path).type);
return response;

Expand Down

0 comments on commit 077f9dc

Please sign in to comment.