Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Don't send default cache header for 301 redirects#18220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfrome-moe:ticket_17139
Jun 15, 2016

Conversation

@e-moe
Copy link
Contributor

@e-moee-moe commentedMar 17, 2016
edited by fabpot
Loading

QA
Branch?"master"
Bug fix?no
New feature?yes
BC breaks?yes
Deprecations?no
Tests pass?yes
Fixed tickets#17139
LicenseMIT
Doc PRsee comments from#17139

thrownew \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).',$status));
}

if (301 ==$status && !array_key_exists('cache-control',$headers)) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not sure if it's correct place for this code. Looking forward for review

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would instead move this into the main Response class just before sending the headers to the client.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@fabpot, in Response class headers already computed and contains unnecessary 'no-cache' directive. We can't check wether is was set automatically or explicitly by user. see\Symfony\Component\HttpFoundation\ResponseHeaderBag::computeCacheControlValue

@javiereguiluzjaviereguiluz changed the title17139: do not send default cache header for 301 redirectsDon't send default cache header for 301 redirectsMar 17, 2016
@e-moe
Copy link
ContributorAuthor

probably we can add$withDefaultCacheControl parameter to\Symfony\Component\HttpFoundation\ResponseHeaderBag::__construct and do something like this:

/**     * Constructor.     *     * @param array $headers An array of HTTP headers     * @param bool $withDefaultCacheControl     */    public function __construct(array $headers = array(), $withDefaultCacheControl = true)    {        parent::__construct($headers);        if ($withDefaultCacheControl && !isset($this->headers['cache-control'])) {            $this->set('Cache-Control', '');        }    }

then, inResponse constructor:

$this->headers = new ResponseHeaderBag($headers, 301 != $status); or, even better check against array like$this->headers = new ResponseHeaderBag($headers, in_array($status, self::$useDefaultCacheControl));

@fabpot
Copy link
Member

I'm going to merge this as is.

@fabpot
Copy link
Member

Thank you@e-moe.

@fabpotfabpot merged commitcf253a9 intosymfony:masterJun 15, 2016
fabpot added a commit that referenced this pull requestJun 15, 2016
This PR was merged into the 3.2-dev branch.Discussion----------Don't send default cache header for 301 redirects| Q             | A| ------------- | ---| Branch?       | "master"| Bug fix?      | no| New feature?  | yes| BC breaks?    | yes| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#17139| License       | MIT| Doc PR        | see comments from#17139Commits-------cf253a9 17139: do not send default cache header for 301 redirects
@fabpotfabpot mentioned this pull requestOct 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@e-moe@fabpot@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp