Skip to content

HttpCache UpdateResponseSubscriber should have a higher priority #3792

@ampaze

Description

@ampaze
Q A
Bug? yes
New Feature? no
Sulu Version 1.6.14

Actual Behavior

The Response is updated by Sulu after the Symfony Response Listener has already been prepared/"fixed up" the Response, meaning that Symfony does not see changes made by Sulu. In my case this lead to pragma and expires headers beeing added, because Symfony thinks the Response should not be cached. Because of this code in Response.php

if ('1.0' == $this->getProtocolVersion() && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
    $this->headers->set('pragma', 'no-cache');
    $this->headers->set('expires', -1);
}

Expected Behavior

Symfony should handle the Response that Sulu is generating.

Steps to Reproduce

I am not sure why the http protocol version is 1.0 when the request reaches Symfony in my setup, so its a bit hard to reproduce. The Apache Configuration is out of my hands unfortunately. One could temporarily remove '1.0' == $this->getProtocolVersion() && in Response.php.

Solution

Just give the UpdateResponseListener a higher priority, eg. in UpdateResponseSubscriber.php

public static function getSubscribedEvents()
{
    return [
        KernelEvents::RESPONSE => ['onResponse', 1000],
    ];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions