Cache expiry does't seem to work if force response caching is set

Created on 30 January 2023, almost 2 years ago
Updated 1 February 2023, almost 2 years ago

Problem/Motivation

I'm trying to debug a plugin for API Proxy where I want to cache API responses when the underlying API doesn't suggest a cache age itself.

Steps to reproduce

  1. Create an API proxy that proxies another API without cache control headers.
  2. Configure it with Cache API responses on and a small TTL (say 30 seconds).
  3. Hit the API proxy end point.
  4. Locate the `cache_page` row in the database..
  5. Notice the `expire` column is set to -1 (permanent).
  6. Notice that multiple hits to the api_proxy route return cached responses.
  7. Notice that flushing all caches removes the row.
  8. Notice that hitting the route again repopulates the row with an expiry of -1 once more.

Proposed resolution

I'm not clear what is happening. I've tried various different configurations in the settings.

I see that setting TTL isn't expected to work with the page cache API. Indeed in this case it seems that page cache rows don't pick up an expiry based on what is set in the API proxy settings UI.
https://www.drupal.org/docs/drupal-apis/cache-api/cache-max-age#s-limita...

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇦🇺Australia queenvictoria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024