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
54c806f8
Commit
54c806f8
authored
5 years ago
by
Jørn Åne
Browse files
Options
Downloads
Patches
Plain Diff
Simplify Module.php static asset cache configuration
parent
96558bb5
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
+13
-31
13 additions, 31 deletions
config-templates/config.php
lib/SimpleSAML/Module.php
+4
-11
4 additions, 11 deletions
lib/SimpleSAML/Module.php
with
17 additions
and
42 deletions
config-templates/config.php
+
13
−
31
View file @
54c806f8
...
...
@@ -862,37 +862,19 @@ $config = [
'production'
=>
true
,
/*
* Set this option to adjust basic caching directives sent by module.php.
*
* Defaults to ['public' => true, 'max_age' => 86400]
*/
// 'module.php.cache' => ['public' => true, 'max_age' => 86400],
/*
* Set this option to adjust expiration timestamp sent by module.php.
* The value (in seconds) is added to current time.
* If set to null, the Expiration header is not sent at all.
*
* Defaults to 10 * 60 (ten minutes).
*/
// 'module.php.expires' => 10 * 60,
/*
* Set this option to make module.php automatically send Etag.
*
* Defaults to false.
*/
// 'module.php.etag' => false,
/*
* Set this option to adjust more caching directives sent by module.php,
* for example must-revalidate. The option takes an array
* where keys are the caching directive names and values are the corresponding values.
*
* Defaults to [] (empty array).
*/
// 'module.php.directives' => [],
* SimpleSAMLphp modules can host static resources which are served through PHP.
* The serving of the resources can be configured through these settings.
*/
'assets'
=>
[
'caching'
=>
[
/**
* These settings adjust the caching headers that are sent
* when serving static resources.
*/
'max_age'
=>
86400
,
'etag'
=>
false
,
],
],
/*********************
| DISCOVERY SERVICE |
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Module.php
+
4
−
11
View file @
54c806f8
...
...
@@ -264,20 +264,13 @@ class Module
}
}
$assetConfig
=
$config
->
getArray
(
'assets'
,
[
'caching'
=>
[
'max_age'
=>
86400
,
'etag'
=>
false
]]);
$response
=
new
BinaryFileResponse
(
$path
);
$cacheSettings
=
$config
->
getArray
(
'module.php.cache'
,
[
'public'
=>
true
,
'max_age'
=>
86400
]);
$response
->
setCache
(
$cacheSettings
);
$cacheExpiration
=
$config
->
getValue
(
'module.php.expires'
,
10
*
60
);
$expires
=
$cacheExpiration
===
null
?
null
:
new
\DateTime
(
'@'
.
(
time
()
+
$cacheExpiration
));
$response
->
setExpires
(
$expires
);
$cacheEtag
=
$config
->
getBoolean
(
'module.php.etag'
,
false
);
if
(
$cacheEtag
)
{
$response
->
setCache
([
'public'
=>
true
,
'max_age'
=>
$assetConfig
[
'caching'
][
'max_age'
]]);
$response
->
setAutoLastModified
();
if
(
$assetConfig
[
'caching'
][
'etag'
])
{
$response
->
setAutoEtag
();
}
$cacheDirectives
=
$config
->
getArray
(
'module.php.directives'
,
[]);
foreach
(
$cacheDirectives
as
$directiveName
=>
$directiveValue
)
{
$response
->
headers
->
addCacheControlDirective
(
$directiveName
,
$directiveValue
);
}
$response
->
isNotModified
(
$request
);
$response
->
headers
->
set
(
'Content-Type'
,
$contentType
);
$response
->
setContentDisposition
(
ResponseHeaderBag
::
DISPOSITION_INLINE
);
...
...
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