Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

octal's avatar
Level 1

Laravel must provide a mean to disable View Caching

Hello, I can't find any way to disable Views caching during development (like in Symfony). I have a problem because I have to integrate some js files in my blade files. The problem is that when I change those js files, the cached view is not aware of that, so laravel do not update it.

0 likes
13 replies
octal's avatar
Level 1

Just using an href on the file (using asset(...) helper) and the js files resides in their own assets/pages/js//.js

in order to get the cached view to integrate the new js file.

In the browser I have to click on Ctrl+PageRefresh_Icon in order to get the browser download the new cached view. If I don't clear the view cache, the browser always download the old cached view with its old js files :(

richard's avatar

You can disable Caching from your browser like this.

Screenshot 2019-03-27 at 16 02 13

tokoiwesley's avatar

In addition to the solution suggested by @richard you need to clear all the compiled view files in your app:

php artisan view:clear
1 like
octal's avatar
Level 1

@TOKOIWESLEY - Caching in the browser is NOT the problem. As I said, I always refresh the browser using Ctrl+Click_On_Refresh_Button which (on Chrome at least) reloads everything. I have to clear the Views Cache with artisan everytime. This slows up the dev process. In Symfony we can simply say

twig:
    cache:  false

This disables the views cache definitely in dev environment.

We need such mechanism in Laravel.

Somone proposed this nice solution

http://easylaravel.com/how-to-disable-views-cache

but this is so heavy to deal with when switching regularly between dev and prod, and it adds an additional layer that we can get rid of if we had the good property in Laravel to deal with that.

Actual solution I found is to simply set the CACHE_DRIVER=array in the .env file (instead of having CACHE_DRIVER=file).

This works but it's still a "fiddling" way to do clean things.

ftiersch's avatar

I'm still not quite clear on the problem.

You have a href in the blade that links (just an example)

{{ asset('assets/pages/js/test.js') }}

Why would view caching be a problem here? The path to the file doesn't change.

octal's avatar
Level 1

I'm asking for a new feature that makes debugging and developping pages easier. This feature exists in other frameworks and really makes sens. Why doesn't Laravel provide such feature?

Caching must ALWAYS be OPTIONAL, not mandatory !!!!

martinbean's avatar

@octal I’m not sure why view caching is the issue here. If you view has a script URL in it (i.e. /js/app.js) then the view is going to fetch the script from that URL. The browser will re-request the file as new if you’re “hard” refreshing, regardless whether the view is cached by Laravel or not.

ftiersch's avatar

@OCTAL - Laravel is a couple years old and used by thousands of people.

I'm gonna go out on a limb here and say that there is another problem here with which we are trying to help you.

If the view would change it would be recompiled so probably the path in the view isn't changing. Is that correct?

octal's avatar
Level 1

Yes the path is not changing in the view

ftiersch's avatar

@OCTAL - Then why would deactivated view caching help if the view itself is not actually changing?

Is there another cache in front of the webserver maybe?

octal's avatar
Level 1

@FTIERSCH - The view changes when u have to add additional js files (via hrefs) in the head of your html.

Please or to participate in this conversation.