Skip to content

Taging via configuration doesn't work for BAN requests #241

Closed
@tomaszhanc

Description

@tomaszhanc

I add tags via YAML file, with configuration similiar to this one:

    fos_http_cache:
        tags:
            rules:
                -
                    match:
                        path: ^/config
                    tag: [config]

It works great for responses, but it doesn't add these tags for BAN request to Varnish after POST method which is returning a status of 201. I checked adding tags via annotation and it works ok there. I've found out that these lines in RuleMatcher are causing the problem:

    $status = array(200, 203, 204, 300, 301, 302, 404, 410);
    if (!empty($this->criteria['additional_cacheable_status'])) {
        $status = array_merge($status, $this->criteria['additional_cacheable_status']);
    }
    if (!in_array($response->getStatusCode(), $status)) {
        return false;
    }

Adding to confgiuration option additional_cacheable_status: [201] solves the problem, but it's a bit tedious to do for every rule. Can we add this status code as a default?

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