Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support language variants for summary and mobile content #1010

Merged
merged 8 commits into from
Jul 30, 2018

Conversation

Pchelolo
Copy link
Contributor

cc @wikimedia/services @berndsi

@Pchelolo Pchelolo requested a review from d00rman June 21, 2018 12:06
@Pchelolo Pchelolo changed the title Support language variants for summary Support language variants for summary and mobile content Jun 21, 2018
Copy link
Contributor

@d00rman d00rman left a comment

Choose a reason for hiding this comment

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

Neatly done!

Now that we implement no-store on the bucket level, we also need to normalise the cache-control header for all incoming requests to RESTBase, though, as we don't want that a client sends it to us. Basically something like:

if (mwUtil.isNoCacheRequest(req)) {
  req.headers['cache-request'] = 'no-cache';
} else {
  delete req.headers['cache-request'];
}

@@ -145,15 +145,16 @@ paths:
request:
method: put
uri: /{domain}/sys/key_value/page_summary/{request.params.title}
headers: '{{merge({"if-none-hash-match": "*"}, extract.headers)}}'
headers: '{{merge({"if-none-hash-match": "*"}, extract.headers, "cache-control": request.headers.cache-control)}}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the request's cache-control being added here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@d00rman to pass through the no-store header.

@Pchelolo
Copy link
Contributor Author

Doesn't Varnish strip those headers?

Change-Id: I4901a437444f3805bbca82df1b1a3c66c41a3d96
Change-Id: Iff004aefb21f43bc530a0ad2cf658baddebf5011
Change-Id: Id994c5adaafaafbe07ab0b9a279e70e3d629296b
Change-Id: Ibca5c9c654a568348454aea6f1bed8aa10f087a4
Change-Id: Ibde9d24247ba202f64d6bb69ce7b08ad791b40e0
Change-Id: I1bb5fbf6edfb9524c6969efe23cde766be2c39e2
@Pchelolo
Copy link
Contributor Author

Rebased

@Pchelolo
Copy link
Contributor Author

All the dependencies were deployed, so we're ready to go fowrward with this.

@d00rman
Copy link
Contributor

d00rman commented Jul 19, 2018

Doesn't Varnish strip those headers?

Yes, Varnish does, but what about internal clients? Better safe than sorry.

EDIT: Also, what about installs that don't count on Varnish being there? The smaller the number of assumptions, the better IMHO

Copy link
Contributor

@d00rman d00rman left a comment

Choose a reason for hiding this comment

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

Two nits, and let's also strip no-store frm incoming requests. To be more precise, let's only leave no-cache and get rid of everything else.

v1/summary.yaml Outdated
catch:
status: 412
status: [ 412, 202 ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's sort these numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

v1/summary.yaml Outdated
return_if:
status: 412
status: [ 412, 202 ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Idem.

Change-Id: I4c1e78be374de1f0723d870f09ca1cb98ee7a156
module.exports = function normalizeHeaders(hyper, req, next) {
if (mwUtil.isNoCacheRequest(req)) {
req.headers['cache-control'] = 'no-cache';
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: else if (req.headers && req.headers['cache-control']) (I wonder if this is needed, i.e. is there somewhere where we ensure the existence of the headers hash?)

Change-Id: I5de0e5b81521f64acee7bc2cab0fe4db2773ef44
@d00rman d00rman merged commit 462fd54 into wikimedia:master Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants