Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting the page cache expiry from controllers #3246

Merged
merged 3 commits into from
Apr 28, 2021

Conversation

lukasbestle
Copy link
Member

@lukasbestle lukasbestle commented Apr 16, 2021

Describe the PR

  • It is now possible to set the page cache expiry timestamp from controllers or templates:
$kirby->response()->expires(1234567890); // timestamp
$kirby->response()->expires('2021-12-31');
  • When setting cache values, you can now define an absolute expiry timestamp instead of the number of minutes. The number of minutes is still supported and auto-detected.

Ready?

  • Added unit tests for fixed bug/feature
  • Added in-code documentation (if needed)
  • CI passes (runs automatically when the PR is created or run composer ci locally)
    Running locally requires PHPUnit, PHP-CS-Fixer, Psalm, PHPCPD and PHPMD.

@lukasbestle lukasbestle added the type: feature 🎉 Adds a feature (requests → feedback.getkirby.com) label Apr 16, 2021
@lukasbestle lukasbestle added this to the 3.5.4 milestone Apr 16, 2021
@lukasbestle lukasbestle requested a review from a team April 16, 2021 09:33
@lukasbestle lukasbestle self-assigned this Apr 16, 2021
lukasbestle added a commit to getkirby/getkirby.com that referenced this pull request Apr 16, 2021
lukasbestle added a commit to getkirby/getkirby.com that referenced this pull request Apr 16, 2021
afbora
afbora previously approved these changes Apr 17, 2021
Copy link
Member

@afbora afbora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great like the getkirby/getkirby.com#1304 PR 👍

@distantnative
Copy link
Member

Two smaller comments. Otherwise looks good, it's a cool feature that makes caching more flexible.

@bastianallgeier
Copy link
Member

I really like this! Makes caching so much more flexible.

@bastianallgeier
Copy link
Member

@lukasbestle I was about to change the method name, but for some reason there's a local issue in my tests with timestamps.

A `$minutes` value of 1000000000 equals 1902 years, so I don't expect anyone to have used such a high value in the past.
@lukasbestle
Copy link
Member Author

I've changed the method name and also added the feature to pass the number of minutes to the expires() method for consistency with the Cache classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature 🎉 Adds a feature (requests → feedback.getkirby.com)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants