5

I'm working on Laravel framework,

I have changed my bootstrap.min.css from v3 to v4 but it's not updated in the browser

I have tried:

php artisan cache:clear
php artisan route:cache
php artisan config:clear
php artisan view:clear
rm -rf bootstrap/cache/*/*

and I deleted the files from storage/framework/views but still, the CSS is not updating.

Can anyone please help me?

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
Sharmila
  • 51
  • 1
  • 1
  • 4

3 Answers3

10

Just add a query string after end of the css file.Then it will not use cached file css. Like ?v=1,?v=2 or any random string.

Example

 <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=1a040064279b" >

you can also use php function (as marco suggested)

?v=echo filemtime();
Akash Kumar Verma
  • 3,185
  • 2
  • 16
  • 32
  • 1
    By doing this you are disabling browser cache completely affecting performance. You could append the filemtime() of the file (https://www.php.net/manual/en/function.filemtime.php) instead of time so the parameter only changes on file change – Marco somefox Sep 29 '22 at 07:59
  • @Marcosomefox thanks a lot for your answer, works perfect!!! – CodeFluid Aug 17 '23 at 04:33
7

For custom CSS file in laravel, use time() function by the following method:

<link rel="stylesheet" type="text/css" href="{{asset('css/style.css?v=').time()}}">

Remember ?v= is just used for getting value by the time() function that will generate random number every time when you refresh the page.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Danish Kazmi
  • 101
  • 2
  • 6
0

This is caused by Chrome's cache. Just follow these steps:

1, Control+Shift+I

2, Click Network > Tick Disable cache

enter image description here

3, Reload Chrome!!

Trinh Hieu
  • 379
  • 3
  • 6