Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a0bae94

Browse filesBrowse files
committed
[HttpFoundation] updated ResponseHeaderBag to compute Cache-Control whenever any of the headers it considers changes
1 parent e8144e4 commit a0bae94
Copy full SHA for a0bae94

File tree

Expand file treeCollapse file tree

2 files changed

+5
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-1
lines changed

‎src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function set($key, $values, $replace = true)
5454
parent::set($key, $values, $replace);
5555

5656
// ensure the cache-control header has sensible defaults
57-
if ('cache-control' === strtr(strtolower($key), '_', '-')) {
57+
if (in_array(strtr(strtolower($key), '_', '-'), array('cache-control', 'etag', 'last-modified', 'expires'))) {
5858
$computed = $this->computeCacheControlValue();
5959
$this->headers['cache-control'] = array($computed);
6060
$this->computedCacheControl = $this->parseCacheControl($computed);

‎tests/Symfony/Tests/Component/HttpFoundation/ResponseHeaderBagTest.php

Copy file name to clipboardExpand all lines: tests/Symfony/Tests/Component/HttpFoundation/ResponseHeaderBagTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@ public function testCacheControlHeader()
5757

5858
$bag = new ResponseHeaderBag(array('cache-control' => 'public, max-age=100'));
5959
$this->assertEquals('max-age=100, public', $bag->get('Cache-Control'));
60+
61+
$bag = new ResponseHeaderBag();
62+
$bag->set('Last-Modified', 'abcde');
63+
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));
6064
}
6165
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.