mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Revert "Don't influence Cache-Control through CACHE_AUTO_PURGE" (#22235)
* Revert "Don't influence Cache-Control through `CACHE_AUTO_PURGE` (#22203)"
This reverts commit 12fb7719fe.
* Add changeset
This commit is contained in:
5
.changeset/breezy-crabs-yell.md
Normal file
5
.changeset/breezy-crabs-yell.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@directus/api': patch
|
||||
---
|
||||
|
||||
Reverted cache-control header change to prevent cache inconsistencies in-app
|
||||
@@ -69,6 +69,50 @@ const scenarios = [
|
||||
output: 'max-age=0',
|
||||
},
|
||||
|
||||
// Test CACHE_AUTO_PURGE env for no-cache
|
||||
{
|
||||
name: 'when CACHE_AUTO_PURGE is true and globalCacheSettings is true',
|
||||
input: {
|
||||
env: {
|
||||
CACHE_AUTO_PURGE: true,
|
||||
},
|
||||
headers: {},
|
||||
accountability: null,
|
||||
ttl: 5678910,
|
||||
globalCacheSettings: true,
|
||||
personalized: false,
|
||||
},
|
||||
output: 'no-cache',
|
||||
},
|
||||
{
|
||||
name: 'when CACHE_AUTO_PURGE is true and globalCacheSettings is false',
|
||||
input: {
|
||||
env: {
|
||||
CACHE_AUTO_PURGE: true,
|
||||
},
|
||||
headers: {},
|
||||
accountability: null,
|
||||
ttl: 5678910,
|
||||
globalCacheSettings: false,
|
||||
personalized: false,
|
||||
},
|
||||
output: 'max-age=5679',
|
||||
},
|
||||
{
|
||||
name: 'when CACHE_AUTO_PURGE is false and globalCacheSettings is true',
|
||||
input: {
|
||||
env: {
|
||||
CACHE_AUTO_PURGE: false,
|
||||
},
|
||||
headers: {},
|
||||
accountability: null,
|
||||
ttl: 5678910,
|
||||
globalCacheSettings: true,
|
||||
personalized: false,
|
||||
},
|
||||
output: 'max-age=5679',
|
||||
},
|
||||
|
||||
// Test personalized
|
||||
{
|
||||
name: 'when personalized is true and accountability is null',
|
||||
|
||||
@@ -24,6 +24,9 @@ export function getCacheControlHeader(
|
||||
// When the resource / current request shouldn't be cached
|
||||
if (ttl === undefined || ttl < 0) return 'no-cache';
|
||||
|
||||
// When the API cache can invalidate at any moment
|
||||
if (globalCacheSettings && env['CACHE_AUTO_PURGE'] === true) return 'no-cache';
|
||||
|
||||
const headerValues = [];
|
||||
|
||||
// When caching depends on the authentication status of the users
|
||||
|
||||
Reference in New Issue
Block a user