skip to Main Content

I use Varnish for my API platform endpoints in a symfony app. API platform version is 2.6 and since I made an upgrade to PHP 8, cache_headers option from API platform config is not working anymore.

I have this configuration for a specific api platform endpoint

collectionOperations:
    voucher_list:
        method: GET
        cache_headers:
            max_age: 3600
            shared_max_age: 3600
        path: /account/{account_id}/vouchers
        requirements:
            account_id: 'd+'
        normalization_context:
            groups: ['voucher_list:read']

This worked perfectly with php 7.4.

Now, Cache-Control has the value no-cache on this endpoint.

Cache-Control will be set only if I set the default configuration in api_platform.yaml

http_cache:
    max_age: 3600
    shared_max_age: 3600
    vary: ['Accept']
    public: true

2

Answers


  1. Chosen as BEST ANSWER

    This issue was fixed with update to latest version of api platform


  2. In your collection operations cache_headers, max age is defined as max-age instead of max_age

    As i see in this documentation https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers

    max_age seems the correct param name.
    As you can see in your generic configuration, you correctly set max_age for http_cache

    Even in api platform 2.6 https://api-platform.com/docs/v2.6/core/performance/#setting-custom-http-cache-headers

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search