Skip to content

expires tag#14969

Merged
brandonkelly merged 9 commits into4.10from
feature/cache-response-tag
May 27, 2024
Merged

expires tag#14969
brandonkelly merged 9 commits into4.10from
feature/cache-response-tag

Conversation

@timkelty
Copy link
Copy Markdown
Contributor

@timkelty timkelty commented May 10, 2024

Description

Adds a expires tag for easier Twig access to \Craft::$app->getResponse()->setCacheHeaders.

// Cache-Control: public, max-age=1814400
{% expires in 3 weeks %}

// Cache-Control: public, max-age=30
{% expires on now|date_modify('+30 seconds') %}

// Cache-Control: no-cache, no-store, must-revalidate
{% expires %}

Based on 4.10 as it is useful for Cloud, but could be rebased to 5.x.

For no-cache, I went with just {% expires %} vs {% expires now %}, as it seemed like with now, we should support more relative times like tomorrow.

@timkelty timkelty requested a review from brandonkelly May 10, 2024 03:18
@timkelty timkelty force-pushed the feature/cache-response-tag branch from b56d22f to b28f4cb Compare May 10, 2024 03:27
@timkelty timkelty changed the title cacheResponse tag expires tag May 25, 2024
@brandonkelly brandonkelly merged commit fd721ca into 4.10 May 27, 2024
@brandonkelly brandonkelly deleted the feature/cache-response-tag branch May 27, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants