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

CommentFileSizeAuthor
#3 api_proxy-setMaxAge-3337433-3.patch494 bytesfran seva

Comments

queenvictoria created an issue. See original summary.

queenvictoria’s picture

Issue summary: View changes
fran seva’s picture

Status: Active » Needs review
StatusFileSize
new494 bytes

Hi - we had the same issue and the problem seems to be the ttl is not being set correctly to cache max age.

arakwar’s picture

I have tested the patch and it does not seems to work, information stays in Drupal cache even if the cache should have expired.

We want a low cache time for this request, about 15 seconds, while the rest of the website have a 1 year cache time. But even after a couple of minutes poking our api proxy endpoint return the cached answer.

I do suspect that caching have evolved in Drupal and Symfony over the last 3 years so there's maybe an update to do on the cache for this module.