Skip to content
Closed
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
4 changes: 3 additions & 1 deletion files/nginx/odk.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ map "$request_method::$uri$is_args$args" $cache_strategy {
~^(GET|HEAD)::/version\.txt$ "revalidate";

# central-backend
~^(GET|HEAD)::/v1/ "passthrough";
~^(GET|HEAD)::/v1/config/public/(hero-image|logo)\?(.*&|)ts=\d+ "immutable";
~^(GET|HEAD)::/v1/config/public/(hero-image|logo)(\?|$) "revalidate";
~^(GET|HEAD)::/v1/ "passthrough";

# central-frontend - unversioned
~^(GET|HEAD)::/$ "revalidate";
Expand Down
23 changes: 23 additions & 0 deletions test/nginx/src/mocha/nginx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,29 @@ function standardTestSuite({ fetchHttp, fetchHttp6, apiFetch, apiFetch6, forward
});
});

describe('backend config blobs', () => {
[
// central-backend public images - frontend always requests with timestamp (`ts=...`)
[ '/v1/config/public/hero-image', 'revalidate' ],
[ '/v1/config/public/hero-image?', 'revalidate' ],
[ '/v1/config/public/hero-image?ts=', 'revalidate' ],
[ '/v1/config/public/hero-image?ts=1776774346923', 'immutable' ],
[ '/v1/config/public/logo?ts=1776774376314', 'immutable' ],
].forEach(([ path, expectedCacheStrategy ]) => {
[ 'GET', 'HEAD' ].forEach(method => {
it(`${method} ${path} should be served with cache strategy: ${expectedCacheStrategy}`, async () => {
// when
const res = await apiFetch(path, { method });

// then
assert.equal(res.status, 200);
// and
assertCacheStrategyApplied(res, expectedCacheStrategy);
});
});
});
});

describe('backend caching', () => {
[
[ '/v1/foo', 'passthrough' ],
Expand Down
Loading