Valet: Disabling the cache for js and css files

Created on 7 Oct 2017  路  2Comments  路  Source: laravel/valet

I'm wondering if there is a convenient way to disable cache for css and js. I tried to modify /usr/local/etc/nginx/valet/valet.conf and add following configuration, but it led to 404 error for all css and js files. Do I miss something? Thanks!

location ~* \.(?:css|js)$ {
  expires -1;
}

Most helpful comment

I had this problem - the easiest solution was to add timestamps to files, something like this:

<script src="/js/my-script.js?{{ time() }}"></script>
<link rel="stylesheet" href="/css/style.css?{{ time() }}" />

Then the files won't cache.

All 2 comments

I had this problem - the easiest solution was to add timestamps to files, something like this:

<script src="/js/my-script.js?{{ time() }}"></script>
<link rel="stylesheet" href="/css/style.css?{{ time() }}" />

Then the files won't cache.

@gzhihao in my case root is set to / I have changed this to my pulbic local folder and 4040 dissapears.

Was this page helpful?
0 / 5 - 0 ratings