Skip to content

Commit

Permalink
pcs: Customize cache control
Browse files Browse the repository at this point in the history
* This patch allows PCS to have customized cache control headers
so we can test optimizations only for the specific endpoint
  • Loading branch information
johngian committed Apr 5, 2023
1 parent 451a258 commit 67d488c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions config.fullstack.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ default_project: &default_project
cache-control: s-maxage=864000, max-age=86400
mobileapps:
host: https://mobileapps.wmcloud.org
cache_control: test_mobileapps_cache_control
wikifeeds:
host: https://wikifeeds-beta.wmflabs.org
summary:
Expand Down
4 changes: 2 additions & 2 deletions projects/v1/wikipedia.wmf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ paths:
- path: v1/pcs/stored_endpoint.js
options:
name: media-list
response_cache_control: '{{options.purged_cache_control}}'
response_cache_control: '{{options.mobileapps.cache_control}}'
host: '{{options.mobileapps.host}}'
disabled_storage: '{{options.disabled_storage}}'
- path: v1/pcs/stored_endpoint.js
options:
name: mobile-html
response_cache_control: '{{options.purged_cache_control}}'
response_cache_control: '{{options.mobileapps.cache_control}}'
host: '{{options.mobileapps.host}}'
disabled_storage: '{{options.disabled_storage}}'
- path: v1/pcs/mobile-html-offline-resources.yaml
Expand Down
4 changes: 2 additions & 2 deletions projects/v1/wikivoyage.wmf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ paths:
- path: v1/pcs/stored_endpoint.js
options:
name: media-list
response_cache_control: '{{options.purged_cache_control}}'
response_cache_control: '{{options.mobileapps.cache_control}}'
host: '{{options.mobileapps.host}}'
- path: v1/pcs/stored_endpoint.js
options:
name: mobile-html
response_cache_control: '{{options.purged_cache_control}}'
response_cache_control: '{{options.mobileapps.cache_control}}'
host: '{{options.mobileapps.host}}'
- path: v1/pcs/mobile-html-offline-resources.yaml
options:
Expand Down
4 changes: 2 additions & 2 deletions projects/v1/wiktionary.wmf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ paths:
- path: v1/pcs/stored_endpoint.js
options:
name: media-list
response_cache_control: '{{options.purged_cache_control}}'
response_cache_control: '{{options.mobileapps.cache_control}}'
host: '{{options.mobileapps.host}}'
- path: v1/pcs/stored_endpoint.js
options:
name: mobile-html
response_cache_control: '{{options.purged_cache_control}}'
response_cache_control: '{{options.mobileapps.cache_control}}'
host: '{{options.mobileapps.host}}'
- path: v1/pcs/mobile-html-offline-resources.yaml
options:
Expand Down
10 changes: 5 additions & 5 deletions test/features/pcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Page Content Service: /page/media-list', () => {
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(!!res.body.items, true);
assert.deepEqual(!!res.headers.etag, true);
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], 'test_mobileapps_cache_control');
});
});

Expand All @@ -46,7 +46,7 @@ describe('Page Content Service: /page/media-list', () => {
assert.deepEqual(res.headers['x-restbase-sunset'] || null, 'true');
assert.deepEqual(!!res.body.items, true);
assert.deepEqual(!!res.headers.etag, true);
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], 'test_mobileapps_cache_control');
});
});

Expand All @@ -59,7 +59,7 @@ describe('Page Content Service: /page/media-list', () => {
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(!!res.body.items, true);
assert.deepEqual(new RegExp(`^(?:W\/)?"${pageRev}\/.+"$`).test(res.headers.etag), true);
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], 'test_mobileapps_cache_control');
});
});
});
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Page Content Service: /page/mobile-html', () => {
assert.deepEqual(res.status, 200);
assert.deepEqual(/^text\/html/.test(res.headers['content-type']), true);
assert.deepEqual(res.headers['x-restbase-sunset'] || null, null);
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], 'test_mobileapps_cache_control');
});
});

Expand All @@ -102,7 +102,7 @@ describe('Page Content Service: /page/mobile-html', () => {
assert.deepEqual(res.status, 200);
assert.deepEqual(/^text\/html/.test(res.headers['content-type']), true);
assert.deepEqual(res.headers['x-restbase-sunset'] || null, 'true');
assert.deepEqual(res.headers['cache-control'], 'test_purged_cache_control');
assert.deepEqual(res.headers['cache-control'], 'test_mobileapps_cache_control');
});
});
});
Expand Down

0 comments on commit 67d488c

Please sign in to comment.