Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
0c14180d
Commit
0c14180d
authored
5 years ago
by
Jørn Åne
Browse files
Options
Downloads
Patches
Plain Diff
Document static asset cache configuration
parent
fa02e492
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config-templates/config.php
+14
-3
14 additions, 3 deletions
config-templates/config.php
lib/SimpleSAML/Module.php
+9
-3
9 additions, 3 deletions
lib/SimpleSAML/Module.php
with
23 additions
and
6 deletions
config-templates/config.php
+
14
−
3
View file @
0c14180d
...
@@ -866,12 +866,23 @@ $config = [
...
@@ -866,12 +866,23 @@ $config = [
* The serving of the resources can be configured through these settings.
* The serving of the resources can be configured through these settings.
*/
*/
'assets'
=>
[
'assets'
=>
[
/*
* These settings adjust the caching headers that are sent
* when serving static resources.
*/
'caching'
=>
[
'caching'
=>
[
/**
/*
* These settings adjust the caching headers that are sent
* Amount of seconds before the resource should be fetched again
* when serving static resources.
*/
*/
'max_age'
=>
86400
,
'max_age'
=>
86400
,
/*
* Calculate a checksum of every file and send it to the browser
* This allows the browser to avoid downloading assets again in situations
* where the Last-Modified header cannot be trusted,
* for example in cluster setups
*
* Defaults false
*/
'etag'
=>
false
,
'etag'
=>
false
,
],
],
],
],
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Module.php
+
9
−
3
View file @
0c14180d
...
@@ -264,11 +264,17 @@ class Module
...
@@ -264,11 +264,17 @@ class Module
}
}
}
}
$assetConfig
=
$config
->
getArray
(
'assets'
,
[
'caching'
=>
[
'max_age'
=>
86400
,
'etag'
=>
false
]]);
$assetConfig
=
$config
->
getConfigItem
(
'assets'
,
new
Configuration
([],
'[assets]'
));
$cacheConfig
=
$assetConfig
->
getConfigItem
(
'caching'
,
new
Configuration
([],
'[assets][caching]'
));
$response
=
new
BinaryFileResponse
(
$path
);
$response
=
new
BinaryFileResponse
(
$path
);
$response
->
setCache
([
'public'
=>
true
,
'max_age'
=>
$assetConfig
[
'caching'
][
'max_age'
]]);
$response
->
setCache
([
// "public" allows response caching even if the request was authenticated,
// which is exactly what we want for static resources
'public'
=>
true
,
'max_age'
=>
(
string
)
$cacheConfig
->
getInteger
(
'max_age'
,
86400
)
]);
$response
->
setAutoLastModified
();
$response
->
setAutoLastModified
();
if
(
$
asset
Config
[
'caching'
][
'etag'
]
)
{
if
(
$
cache
Config
->
getBoolean
(
'etag'
,
false
)
)
{
$response
->
setAutoEtag
();
$response
->
setAutoEtag
();
}
}
$response
->
isNotModified
(
$request
);
$response
->
isNotModified
(
$request
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment