Skip to content

Commit

Permalink
Merge pull request #599 from flightphp/cache-correction
Browse files Browse the repository at this point in the history
Corrected the cache behavior in some areas
  • Loading branch information
n0nag0n authored Jul 13, 2024
2 parents 8dd255c + 4a93c66 commit 7cfaca8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions flight/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ public function _error(Throwable $e): void

try {
$this->response()
->cache(0)
->clearBody()
->status(500)
->write($msg)
Expand Down Expand Up @@ -736,6 +737,10 @@ public function _delete(string $pattern, $callback, bool $pass_route = false, st
*/
public function _halt(int $code = 200, string $message = '', bool $actuallyExit = true): void
{
if ($this->response()->getHeader('Cache-Control') === null) {
$this->response()->cache(0);
}

$this->response()
->clearBody()
->status($code)
Expand Down
2 changes: 1 addition & 1 deletion flight/net/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function clear(): self
*/
public function cache($expires): self
{
if ($expires === false) {
if ($expires === false || $expires === 0) {
$this->headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$this->headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
$this->headers['Pragma'] = 'no-cache';
Expand Down

0 comments on commit 7cfaca8

Please sign in to comment.