Skip to content

[optimizer] allow http caching for bundles#15880

Merged
epixa merged 1 commit intoelastic:masterfrom
epixa:cachecontrol
Jan 9, 2018
Merged

[optimizer] allow http caching for bundles#15880
epixa merged 1 commit intoelastic:masterfrom
epixa:cachecontrol

Conversation

@epixa
Copy link
Contributor

@epixa epixa commented Jan 7, 2018

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.

Even though we were sending the last-modified header before, the
browser wasn't actually caching anything because a no-cache value was
being sent for cache-control.

Closes #6520

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.
@epixa epixa added release_note:enhancement v6.2.0 v7.0.0 Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// review labels Jan 7, 2018
@bmcconaghy bmcconaghy self-requested a review January 8, 2018 14:10
Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Member

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Verified 304 (Not Modified) responses for unchanged assets and 200 for updated assets.

@epixa epixa merged commit 0378966 into elastic:master Jan 9, 2018
@epixa epixa deleted the cachecontrol branch January 9, 2018 16:12
epixa added a commit to epixa/kibana that referenced this pull request Jan 9, 2018
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.
epixa added a commit that referenced this pull request Jan 9, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:enhancement review Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v6.2.0 v7.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants