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

[9.x] Add option to disable cached view #41859

Merged
merged 3 commits into from
Apr 7, 2022
Merged

[9.x] Add option to disable cached view #41859

merged 3 commits into from
Apr 7, 2022

Conversation

bernardwiesner
Copy link
Contributor

@bernardwiesner bernardwiesner commented Apr 7, 2022

Especially during development its very helpful to disable the cached views. Here are a few use cases:

  • Switching domains on local from 127.0.0.1 to local-your-domain.com on local (such as when using ssl certificates)
    When switching domains the same compiled view is returned using the old domain in JS, CSS, etc.

  • Custom implementation that add modify contents on compile time, such as custom cache busters for JS.
    Adding a query string to JS for cache busting done with PHP at compile time.

And many other use cases where view caching might not be desirable on local.

Relates to: #2501

Would enable inside config/view.php using

'cache' => App::environment('local') ? false : true

@taylorotwell taylorotwell merged commit bb9a897 into laravel:9.x Apr 7, 2022
@xxdalexx
Copy link

xxdalexx commented Apr 27, 2022

This comes with a big caveat of test speed.
For the project I tried this on, running the full suite not in parallel:
With View Caching: 4.8 Seconds
Without: 1 Minute, 19 Seconds

A work around is to point your config to a .env variable to disable view caching for local serving, and enabling it in the phpunit.xml for testing.

@bernardwiesner
Copy link
Contributor Author

@xxdalexx
Thanks for pointing out, however I think most folks won't have an issue since by default phpunit.xml is already set to testing environment.
https://github.com/laravel/laravel/blob/d0603437cbbb478586979a3792d49e0d157ce554/phpunit.xml#L21

@joelmellon
Copy link
Contributor

@bernardwiesner Thanks! Great feature.

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.

4 participants