prohibit IIS cache static files (png, js, html, etc.) Background:
IIS to improve performance, by default will be static The files js, html, gif, png, etc. do internal caching, which is in the memory of the server iis process. IIS does this to a large extent to improve the access performance of static files. Under normal circumstances, as long as the static file is updated, IIS will also update the cache. However, if there are many static files updated, there may be cases where the cache is not updated.
Detour:
I have encountered such a scenario, the server cyclically updates tens of thousands of stock quotes, IIS will also cache the images, due to the high frequency of updates, many files, There have been cases where the IIS cache file could not be updated for more than a few minutes.
At this time, the intuition is that the browser caches the file, so the Http header is set in the IIS directory: Cache-Control: no-cache, but it does not help, the browser requests the server to get the status number is 200, this can indicate that the browser did get new content from the server side instead of reading the browser local cache.
How to disable IIS to cache static files (png, js, html, etc.):
The method of setting the Http header to prevent the browser from caching is not feasible in this scenario, because the cache is not The client appears, but appears on the IIS server; so the problem needs to start from IIS itself, by configuring the Metabase.xml file to prohibit IIS from caching the static files in the corresponding directory.
1. First need to set IIS to allow the runtime to edit the Metabase.xml file
Open IIS, then open the IIS property page, check the "Allow direct editing of the configuration database" option < Br>
2. Enter notepad c:\\WINDOWS\\system32\\inetsrv\\MetaBase.xml in the run to open the IIS configuration file
3. Search for the virtual directory name to be cached in the file. Similar to the following configuration section
<IIsWebVirtualDir Location="/LM/W3SVC/1832041641/root/inc"
AccessFlags="AccessRead |
AccessScript"
AppFriendlyName="inc"
AppIsolated="2"
AppRoot="/LM/W3SVC/1832041641/Root/inc"
DirBrowseFlags="DirBrowseShowDate |
DirBrowseShowTime |
DirBrowseShowSize |
DirBrowseShowExtension |
DirBrowseShowLongDate |
EnableDefaultDoc"
Path="D:\\publish\\inc"
>
</IIsWebVirtualDir>
Add MD_VR_NO_CACHE=”1” attribute in the IIsWebVirtualDir configuration section
4. Save the configuration file and restart IIS.
If you want to configure all the sites on the server, disable IIS cache by modifying the registry:
Edit DisableStaticFileCache in the registry Value, 0 is enabled, 1 is disabled, the key value is located at: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\InetInfo\\Parameters
If the key does not exist, it can be created.
Notes :
Under normal circumstances, we do not need to disable IIS's static file cache. iis will automatically update the cache automatically according to the modification time of the static file; it is only necessary to disable IIS cache if you encounter extreme conditions. IIS There is no relationship between the cache and the Http cache related header. There is no way to clear the IIS cache of static files by adding a cache header to IIS.
Selecting protection for a virtual infrastructure is like buying an anti-virus software product for
Still being hacked for the site. Worried about being able to run executable files
can not upload large files Request object error ASP 0104: 80004005 or after successfully uploaded, t
Backing up and restoring Windows IIS server settings
Web server installation and operation of FTP detailed steps
Win2000 installation and server configuration (below)
Restore Win2000/XP administrator password
How Win 2000 makes FTP server more secure
Nginx location syntax description
How to choose server host in cloud computing era
Set the server to be able to support shtml file
IIS 6's best configuration method for
What issues should you pay attention to when migrating a file server?
Win10 prompts the computer graphics card memory shortage situation solution
How to make Win8 system run faster
What if Win10 can't drag files? Win10 system can not drag files solution
Microsoft officially released Windows 8 feature information summary
Linux Shell text processing command summary
What should I do if I get Error 1935 when installing the software on Win7 system?
How to open the microphone listening function
Win10 prompts printer service when using printer. How to turn on printer service
Win10 mobile phone preview version of the error code 80073cf6 how to do