0

The problem is that I change the js files that are in the public folder. But after I upload them to the server using git, nothing changes on the server and the site appears as if it is the old js. Although even if I go through the server and see the content of the file, it is updated.

I tried clearing laravel caches. php artisan view:clear php artisan route:cache php artisan cache:cl php artisan optimize:clear I've tried clearing the server's own cache. Also I updated my browser cache and it still doesn't work.

It only helps if I rename the file to a name I have not named yet. Then it will be updated on the site.

Sergei
  • 3
  • 3
  • you seem to have browser based caching enabled on server.... you need to check htaccess or nginx conf depending on the server... .. please also check if you have some cnd like cloudflare enabled as well because cdns do cache static resources.... – Anant V Apr 29 '23 at 12:08
  • you can change files either by renaming as you are doing or by appending query string at the end of the file like ```style.css?v=1.1``` ...... this willl force browser to download fresh copy of asset...this is the naive way to do it.... – Anant V Apr 29 '23 at 12:10
  • you may also refer to this [asnwer](https://stackoverflow.com/questions/1922910/force-browser-to-clear-cache) on stack overflow – Anant V Apr 29 '23 at 12:13
  • Someone to help me please https://stackoverflow.com/questions/76136964/color-thief-text – user21760787 Apr 29 '23 at 23:18

2 Answers2

0

After double-checking everything related to your file, including Git, file paths, and other aspects, you can try renaming the file. If renaming the file leads to the updated version being displayed on the site, it suggests that the issue might be related to caching mechanisms. In such cases, you can consider implementing cache-busting techniques like appending a query parameter with a unique value to the file URL (e.g., script.js?v=1234). This ensures that the browser always fetches the updated file.

Please note that it's always a good idea to thoroughly investigate and address the root cause of the caching issue to prevent it from reoccurring in the future.

0

Are you sure your public folder isn't included in the .gitignore file? You can also check if your remote repository is getting updated or not.

By the way, using php artisan optimize:clear is enough, you don't need to run all those.

Wakil Ahmed
  • 1,053
  • 1
  • 8
  • 16