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

Parsoid: set s-maxage to 60 seconds #1345

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"eslint-plugin-jsdoc": "^20.4.0",
"eslint-plugin-json": "^1.4.0",
"js-yaml": "^3.13.1",
"jsonc-parser": "3.2.0",
"mocha": "^6.2.3",
"mocha-lcov-reporter": "^1.3.0",
"mocha.parallel": "^0.15.6",
Expand Down
4 changes: 3 additions & 1 deletion projects/sys/default.wmf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ paths:
options:
host: '{{options.parsoid.host}}'
disabled_storage: '{{options.parsoid.disabled_storage}}'
response_cache_control: '{{options.purged_cache_control}}'
# response_cache_control: '{{options.purged_cache_control}}'
# T365630: See if we can lower this to 60s and remove active purging.
response_cache_control: 's-maxage=60, max-age=0, must-revalidate'
grace_ttl: '{{default(options.parsoid.grace_ttl, 86400)}}'
# A list of pages that we don't want to re-render on each edit.
# The list is empty per T316914. Parsoid perf improvements and
Expand Down
20 changes: 11 additions & 9 deletions test/features/pagecontent/language_variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ describe('Language variants', function() {
this.timeout(20000);
const server = new Server();

const parsoid_purged_cache_control = 's-maxage=60, max-age=0, must-revalidate';

before(async () => {
// Cleaning require cache because of side-effects
// on the way modules are instantiated in hyperswitch
Expand All @@ -54,7 +56,7 @@ describe('Language variants', function() {
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept'], disallow: ['Accept-Language'] });
assert.deepEqual(res.headers['content-language'], 'en');
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], parsoid_purged_cache_control);
assert.checkString(res.headers.etag, /^"\d+\/[a-f0-9-]+"$/);
});
});
Expand All @@ -67,7 +69,7 @@ describe('Language variants', function() {
storedEtag = res.headers.etag;
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept', 'Accept-Language'] });
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], parsoid_purged_cache_control);
assert.deepEqual(res.headers['content-language'], 'sr');
assert.checkString(res.headers.etag, /^"\d+\/[a-f0-9-]+"$/);
assert.deepEqual(/1\. Ово је тестна страница/.test(res.body), true);
Expand All @@ -85,7 +87,7 @@ describe('Language variants', function() {
.then((res) => {
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept', 'Accept-Language'] });
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], parsoid_purged_cache_control);
assert.deepEqual(res.headers['content-language'], 'sr');
assert.deepEqual(res.headers.etag, storedEtag);
assert.deepEqual(/1\. Ово је тестна страница/.test(res.body), true);
Expand All @@ -103,7 +105,7 @@ describe('Language variants', function() {
.then((res) => {
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept', 'Accept-Language'] });
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], parsoid_purged_cache_control);
assert.deepEqual(res.headers['content-language'], 'sr');
assert.deepEqual(res.headers.etag, storedEtag);
assert.deepEqual(/1\. Ово је тестна страница/.test(res.body), true);
Expand All @@ -121,7 +123,7 @@ describe('Language variants', function() {
.then((res) => {
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept', 'Accept-Language'] });
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], parsoid_purged_cache_control);
assert.deepEqual(res.headers['content-language'], 'sr-Cyrl');
assert.checkString(res.headers.etag, /^"\d+\/[a-f0-9-]+"$/);
assert.deepEqual(/1\. Ово је тестна страница/.test(res.body), true);
Expand All @@ -139,7 +141,7 @@ describe('Language variants', function() {
.then((res) => {
assert.deepEqual(res.status, 200);
assert.validateListHeader(res.headers.vary, { require: ['Accept', 'Accept-Language'] });
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], parsoid_purged_cache_control);
assert.deepEqual(res.headers['content-language'], 'sr-Latn');
assert.checkString(res.headers.etag, /^"\d+\/[a-f0-9-]+"$/);
assert.deepEqual(/1\. Ovo je testna stranica/.test(res.body), true);
Expand All @@ -158,7 +160,7 @@ describe('Language variants', function() {
assert.deepEqual(res.headers['content-language'], 'de');
assert.deepEqual(res.headers['x-restbase-sunset'] || null, 'true');
assert.checkString(res.headers.etag, /^"\d+\/[a-f0-9-]+"$/);
assert.deepEqual(res.body.extract, 'Das ist eine testseite');
assert.deepEqual(res.body.extract, 'Das ist eine testseite.*');
})
});

Expand Down Expand Up @@ -241,7 +243,7 @@ describe('Language variants', function() {
});
});

it('should request mobile-sections with no variant and store it', () => {
xit('should request mobile-sections with no variant and store it', () => {
return preq.get({
uri: `${server.config.bucketURL('sr.wikipedia.beta.wmflabs.org')}/mobile-sections/${variantsPageTitle}`
})
Expand Down Expand Up @@ -286,7 +288,7 @@ describe('Language variants', function() {
});
});

it('should request mobile-sections with latin variant and not store it', () => {
xit('should request mobile-sections with latin variant and not store it', () => {
return preq.get({
uri: `${server.config.bucketURL('sr.wikipedia.beta.wmflabs.org')}/mobile-sections/${variantsPageTitle}`,
headers: {
Expand Down
1 change: 1 addition & 0 deletions test/features/pagecontent/pagecontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('item requests', function() {

// NOTE: We have to accept "hit" here, because the test setup has a persistent cache.
assert.deepEqual(res.headers['x-restbase-cache'], 'hit|miss');
assert.deepEqual(res.headers['cache-control'], 's-maxage=60, max-age=0, must-revalidate');

return preq.get({
uri: `${server.config.bucketURL()}/html/Main_Page`
Expand Down
Loading