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

How to cache paginated urls? #97

Open
hmzisb opened this issue Jan 26, 2022 · 3 comments
Open

How to cache paginated urls? #97

hmzisb opened this issue Jan 26, 2022 · 3 comments

Comments

@hmzisb
Copy link

hmzisb commented Jan 26, 2022

Paginated pages return the same content as first page. As there any way around it?

@1stwebdesigns
Copy link

@hmzisb the issue is that Laravel uses a query string for pagination. I did see a solution for caching views that have query string parameters, but I don't particularly like this because a bot could generate a huge number of cached files by just changing the query string slightly each time.

The solution I used was to implement pretty pagination - that is where the page number forms part of the route, rather than using a query string. I used this package: https://github.com/michaloravec/laravel-paginateroute

So your URLs become /products/widgets/2 rather than /products/widgets?page=2

@hmzisb
Copy link
Author

hmzisb commented Jan 26, 2022

@1stwebdesigns Thanks for the help. I saw this package but it seems like it hasn't been maintained in the last three years. Does it still work with the latest version of laravel?

@1stwebdesigns
Copy link

1stwebdesigns commented Jan 26, 2022

@hmzisb Yes it works fine - although it was created 3 years ago I have seen the author reference it on the Laravel forum more recently. In my case it was a choice between disabling the caching of paginated pages, implementing a work-around to cache pages with query strings, or implement pretty pagination. The latter seemed the lesser of 3 evils. Not to mention I think pretty pagination looks nicer, so there is a benefit there.

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

No branches or pull requests

2 participants