How to disable single file caching in IIS 7 using weserver configuration settings

Is there a way to reinstall the caching of a single javascript file in my ASP.NET application without disabling caching of any other files in the application?

It runs on IIS 7 in Azure, so it seems to me that my only control options for this are in the web server tags.

I am currently using the folowwing configuration, but this disables the cache for all files.    

     <modules runAllManagedModulesForAllRequests="true"/>

    <staticContent>
      <clientCache cacheControlMode="DisableCache"/>
    </staticContent>

  </system.webServer>

I just want to disable the cache of a single javascript file, which changes quite often.

Is it possible?

+25
source share
6 answers

; :

<configuration>
  <location path="path/to/the/file">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlMode="DisableCache" />
      </staticContent>
    </system.webServer>
  </location>
</configuration>

( , web.config)

web.config, ;

<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Cache-Control" value="no-cache" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

[ IIS7.5 Windows 7, , Azure]

+33

, "profiles"

<caching>
  <profiles>
    <add extension=".js" kernelCachePolicy="DontCache" policy="DontCache"/>
  </profiles>
</caching>
+8

System.WebServer/Caching, . , , Javascript, .js.

<system.webServer>
...

   <caching>
      <add extension=".js" policy="DontCache" kernelCachePolicy="DontCache" />
   </caching>

</system.webServer>

.js , .

, web.config , , .js . , , .


, IIS, config:

/: http://www.iis.net/ConfigReference/system.webServer/caching

//: http://www.iis.net/ConfigReference/system.webServer/caching/profiles

///: http://www.iis.net/ConfigReference/system.webServer/caching/profiles/add

, .

, HTTP-, IIS,

**, IIS Azure, , Dev Azure.

+7

, , web.config,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
        <caching>
            <profiles>
                <remove extension=".js" />
            </profiles>
        </caching>

  </system.webServer>
</configuration>

, .js

+3

, , :
(. fooobar.com/questions/9762/...)

<configuration>
    <location path="cache.manifest">
      <system.webServer>
        <staticContent>
          <clientCache cacheControlMode="DisableCache" />
        </staticContent>
      </system.webServer>
    </location>
</configuration>
0

IIS.

, , .

, " ".

From there, select the HTTP response headers, click "Add" to add a new header, add the "Cache-Control" header with a "no-cache" value.

0
source

Source: https://habr.com/ru/post/1624436/


All Articles