Skip to content

Commit

Permalink
no-cache requests write to cache even when storage is disabled.
Browse files Browse the repository at this point in the history
So allow us to safely switch back from disabled_storage, we need to keep
pre-generated cache entries up to date. We can do this by simply
continuing to handle no-cache requests as we did before, allowing them
to write updated renderings to the cache.

Change-Id: Ica6f52b362d37765471ab1ed37dee62a8e0ca6f7
  • Loading branch information
brightbyte committed Oct 12, 2023
1 parent 1db7b95 commit cab8586
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sys/parsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,19 @@ class ParsoidService {
let contentReq;

const disabledStorage = this._isStorageDisabled(req.params.domain);
const isNoCacheRequest = mwUtil.isNoCacheRequest(req);

if (!disabledStorage) {
if (disabledStorage && !isNoCacheRequest) {
contentReq = this._getPageBundleFromParsoid(hyper, req);
} else {
contentReq = this._getContentWithFallback(
hyper, rp.domain, rp.title, rp.revision, rp.tid
).then((res) => {
res.headers['x-restbase-cache'] = res.headers['x-restbase-cache'] || 'hit'; // FIXME: miss?
return res;
});

if (mwUtil.isNoCacheRequest(req)) {

if (isNoCacheRequest) {
// Check content generation either way
contentReq = contentReq.then((res) => {
res.headers['x-restbase-cache'] = 'nocache';
Expand All @@ -581,8 +583,6 @@ class ParsoidService {
// Only (possibly) generate content if there was an error
contentReq = contentReq.catch(generateContent);
}
} else {
contentReq = this._getPageBundleFromParsoid(hyper, req);
}

return contentReq
Expand Down

0 comments on commit cab8586

Please sign in to comment.