mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.23k stars 212 forks source link

Pagination links are incorrectly cached when the website has multiple domains #407

Open Drewdan opened 2 years ago

Drewdan commented 2 years ago

Describe the bug

If you have a website which has multiple domains, and subsequently multiple sessions, you might visit a page showing paginated resources, and the class which has the pagination data, such as the path for the links is cached. This means the baseURL for the pagination links is also cached, and won't change when the URL of the website changes.

For example: go to mywebsite.com - and load a page with paginated data - the links will show with the correct URL process to mywebsite.app - and loads the same page with paginated data - the links will show with the previous URL, not the current one.

Eloquent Query Please provide the complete eloquent query that caused the bug, for example:

User::paginate();

Stack Trace N.A

Environment

Additional context

This behaviour is not too unpleasant and quite edge casey, however, it does get confusing when a pagination link changes your domain from one to another, and then you lose your session.

I have a fix in mind, and the PR will follow.