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
[4.x] Warm paginated pages with static:warm
command
#9493
Open
duncanmcclean
wants to merge
13
commits into
4.x
Choose a base branch
from
warm-paginated-pages
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
duncanmcclean
changed the title
[4.x] Warm paginated pages
[4.x] Warm paginated pages with Feb 8, 2024
static:warm
command
By default, we'll have the `page` query parameter in here so pagination works. However, if you change the pagination param name or have some other query parameter you want to whitelist, then that setting lets you do that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements warming of paginated pages into the
static:warm
command. This will be especially useful for larger sites which have lots of pagination pages since right now, only the first page is warmed.Under the hood, Statamic's
Cache
middleware checks if there's a paginator instance being "blinked". If there is, a header is added to the response containing the URL of the next paginated page.This header then gets picked up by the
static:warm
command and triggers the paginated page to be warmed, which happens in a loop until there's no more paginated pages to warm.The implementation is inspired by statamic/ssg#140.
Working around the
ignore_query_strings
config optionRight now, you can't use pagination at all with the
ignore_query_strings
config option enabled. This PR adds the ability to whitelist certain query parameters, like thepage
query param used for pagination.I've made this a config option rather than hard-coding
page
so it's flexible in case you have a reason for a query parameter changing the outputted HTML.One downside to this approach (which is potentially a non-issue, depending on your reason for using the ignore setting in the first place) is that the allowed query parameters can be used on any page, even where it's not used, and it would result in a separate page in the cache.
For example: If you have
page
on the allow list and only have a "News" page with pagination on it, users could append?page=whatever
to any page and a separate page would be created in the cache.To Do
ignore_query_strings
settingpage
(or whatever the page name you've defined)/
in the list of warmed URIs