Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improved Cache-Control header when no-cache is sent

  • Loading branch information...
commit 22c6b2c0c2305048b75b35d16c4e74cecdf5b122 1 parent aad8136
@dlsniper authored
Showing with 16 additions and 2 deletions.
  1. +16 −2 src/Symfony/Component/HttpFoundation/Response.php
View
18 src/Symfony/Component/HttpFoundation/Response.php
@@ -143,6 +143,14 @@ public function prepare()
if ($this->headers->has('Transfer-Encoding')) {
$this->headers->remove('Content-Length');
}
+
+
+ // Check if we need to send extra expire info headers
+ if ('1.0' == $this->getProtocolVersion() && 'no-cache' == $this->headers->get('Cache-Control')) {
+ $this->headers->set('pragma', 'no-cache');
+ $this->headers->set('expires', -1);
+ }
+
}
/**
@@ -525,8 +533,14 @@ public function getMaxAge()
return $age;
}
- if (null !== $this->getExpires()) {
- return $this->getExpires()->format('U') - $this->getDate()->format('U');
+ $expiry = $this->getExpires();
+
+ if (!$expiry instanceof \DateTime && (-1 == $expiry || 0 === $expiry)) {
+ return $expiry;
+ }
+
+ if (null !== $expiry) {
+ return $expiry->format('U') - $this->getDate()->format('U');
}
return null;
Please sign in to comment.
Something went wrong with that request. Please try again.