Skip to content

Commit

Permalink
Parsoid: set s-maxage to 60 seconds
Browse files Browse the repository at this point in the history
This sets s-maxage for Parsoid to 60 seconds. If we can get away with
this, we can disable active purging (and don't need to implement active
purging for the equivalent core endpoints).

Bug: T365630
Change-Id: Ifad202d8f0df5bc383151aa534091e9e16795ffa
  • Loading branch information
brightbyte authored and johngian committed Jun 11, 2024
1 parent 81218db commit fc5cf20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
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
16 changes: 9 additions & 7 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
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

0 comments on commit fc5cf20

Please sign in to comment.