Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable cache for some files in google chrome DevTools

Whenever I run the project, many files(CSS, image and js) requested from a remote server and the project load slowly.

For handling this issue, I unchecked disable cache for all files in the network tab of Chrome DevTools(for caching all files) as follows:

disable cache for some files in chrome

But the problem started when I need some files(for example test.js,...) don't cache because they change quickly.

How to disable cache for some files(JS, CSS,...) in google chrome DevTools?

like image 401
Iman Bahrampour Avatar asked Oct 20 '17 19:10

Iman Bahrampour


People also ask

Can I clear specific cache in Chrome?

Here's how to clear the browser cache for just one web page: Open the webpage you want to clear the cache for, and go into Chrome Developer Tools. That's CMD+Option+I on a Mac, and CTRL+Shift+I or F12 on Windows, Linux, and Chromebooks. Click Empty Cache and Hard Reload in the list of options, and you're done.

How do I limit Chrome cache?

Limit Chrome cache size in Windows 10After opening it, right-click on the Chrome icon in the taskbar. In the list, right-click on “Google Chrome” and select “Properties“. In the “Target” field, add --disk-cache-size=1073741824 flag at the end of the file path. Click on the “Ok” button to save the changes.


1 Answers

There are many ways to disable cache for specific files.

Maybe the two most common are:

  1. The build-in bundle system of .net
  2. Add query to your script file name ie:

    <script src="../whatever/someFile.js?version=1234" />
    //Where version can be a variable taken from web.config or DateTime.Now() of some sort.
    
like image 153
Ziv Weissman Avatar answered Sep 23 '22 01:09

Ziv Weissman