Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cache_control_override
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
cache_control_override
Merge requests
!8
Issue
#3350593
: Use s-maxage instead of max-age
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Open
Issue
#3350593
: Use s-maxage instead of max-age
issue/cache_control_override-3350593:3350593-use-s-maxage-instead
into
2.0.x
Overview
0
Commits
4
Pipelines
0
Changes
1
Open
Issue #3350593: Use s-maxage instead of max-age
Pierre Rudloff
requested to merge
issue/cache_control_override-3350593:3350593-use-s-maxage-instead
into
2.0.x
Mar 27, 2023
Overview
0
Commits
4
Pipelines
0
Changes
1
0
0
Merge request reports
Compare
2.0.x
version 3
45a0d96a
Mar 27, 2023
version 2
dc9a0906
Mar 27, 2023
version 1
acef7baf
Mar 27, 2023
2.0.x (HEAD)
and
latest version
latest version
da58d38e
4 commits,
Mar 31, 2023
version 3
45a0d96a
3 commits,
Mar 27, 2023
version 2
dc9a0906
2 commits,
Mar 27, 2023
version 1
acef7baf
1 commit,
Mar 27, 2023
1 file
+
18
−
17
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/EventSubscriber/CacheControlOverrideSubscriber.php
+
18
−
17
View file @ bab76318
Edit in single-file editor
Open in Web IDE
Show full file
@@ -65,25 +65,26 @@ final class CacheControlOverrideSubscriber implements EventSubscriberInterface {
$maxAge
=
(
int
)
$response
->
getCacheableMetadata
()
->
getCacheMaxAge
();
// We treat permanent cache max-age as default therefore we don't override
// the max-age.
if
(
$maxAge
!==
CacheBackendInterface
::
CACHE_PERMANENT
)
{
// If max-age is not uncacheable (0), check if max-age should be changed.
if
(
$maxAge
>
0
)
{
// Force minimum max-age if configured.
$minimum
=
$this
->
getMaxAgeMinimum
();
if
(
$minimum
!==
NULL
)
{
$maxAge
=
max
(
$minimum
,
$maxAge
);
}
// Force maximum max-age if configured.
$maximum
=
$this
->
getMaxAgeMaximum
();
if
(
$maximum
!==
NULL
&&
$maximum
!==
CacheBackendInterface
::
CACHE_PERMANENT
)
{
$maxAge
=
min
(
$maximum
,
$maxAge
);
}
if
(
$maxAge
==
CacheBackendInterface
::
CACHE_PERMANENT
)
{
// Permanent is -1 so we must replace it with the value from core configuration.
$maxAge
=
$this
->
configFactory
->
get
(
'system.performance'
)
->
get
(
'cache.page.max_age'
);
}
// If max-age is not uncacheable (0), check if max-age should be changed.
if
(
$maxAge
>
0
)
{
// Force minimum max-age if configured.
$minimum
=
$this
->
getMaxAgeMinimum
();
if
(
$minimum
!==
NULL
)
{
$maxAge
=
max
(
$minimum
,
$maxAge
);
}
// Force maximum max-age if configured.
$maximum
=
$this
->
getMaxAgeMaximum
();
if
(
$maximum
!==
NULL
&&
$maximum
!==
CacheBackendInterface
::
CACHE_PERMANENT
)
{
$maxAge
=
min
(
$maximum
,
$maxAge
);
}
$response
->
headers
->
set
(
'Cache-Control'
,
'public, max-age='
.
$maxAge
);
}
$response
->
headers
->
set
(
'Cache-Control'
,
'public, max-age=0, must-revalidate, s-maxage='
.
$maxAge
);
}
/**
Loading