Is there an ISAPI filter that can automatically add the Last-Modified header in IIS?
Automatically add Last-Modified header IIS
iisisapilast-modified
Related Solutions
According to RFC 2616 section 13.3.4, an HTTP 1.1 Client MUST use the ETag in any cache-conditional requests, and if both an ETag and Last Modified are present, it SHOULD use both. The ETag header is considered a strong validator (see section 13.3.3), unless explicitly declared weak by the server, whereas the Last Modified header is considered weak unless at least a minute difference exists between it and the Date header. Note, however that the Server is not required to send either (but it SHOULD, if it can).
Note that the Client does not check the headers to see if they have changed; it just blindly uses them in the next conditional request; it is up to the Server to evaluate whether to send the requested content or a 304 Not Modified response. If the Server only sends one, then the Client will use that one alone (although, only strong validators are useful for a Range request). Of course, it is also at the discretion of intermediate caches (unless they have been prevented from caching via Cache Control directives) and the Server as to how they will act upon the headers; the RFC states that they MUST NOT return a 304 Not Modified if the validators are inconsisent, but since the header values are generated by the server, it has quite a bit of leeway.
In practice, I have noticed that Chrome, FireFox, and IE 7+ all send both headers, if available. I also tested the behavior when sending modified headers, which I had already suspected from the information in the RFC. The four clients I tested only sent conditional requests if the page(s) were refreshed or if it was the first time the page had been requested by the current process.
This is what worked for me (Updated for VS 2013, see revision history for 2010, for VS 2015 see this: https://stackoverflow.com/a/32744234/218971):
Right-click your Web Application Project ▶
Properties
▶Web
, then configure theServers
section as follows:- Select IIS Express ▼ from the drop down
- Project Url:
http://localhost
- Override application root URL:
http://dev.example.com
- Click Create Virtual Directory (if you get an error here you may need to disable IIS 5/6/7/8, change IIS's
Default Site
to anything but port:80
, make sure Skype isn't using port 80, etc.)
Optionally: Set the
Start URL
tohttp://dev.example.com
Open
%USERPROFILE%\My Documents\IISExpress\config\applicationhost.config
(Windows XP, Vista, and 7) and edit the site definition in the<sites>
config block to be along the lines of the following:<site name="DevExample" id="997005936"> <application path="/" applicationPool="Clr2IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\path\to\application\root" /> </application> <bindings> <binding protocol="http" bindingInformation=":80:dev.example.com" /> </bindings> <applicationDefaults applicationPool="Clr2IntegratedAppPool" /> </site>
If running MVC: make sure the
applicationPool
is set to one of the "Integrated" options (like "Clr2IntegratedAppPool").Open your
hosts
file and add the line127.0.0.1 dev.example.com
.► Start your application!
Some great advice from the comments:
- You may need to run Visual Studio as Administrator.
- If you want to make other devs see your IIS run
netsh http add urlacl url=http://dev.example.com:80/ user=everyone
- If you want the site to resolve for all hosts set
bindingInformation="*:80:"
. Use any port you want, 80 is just convenient. To resolve all hosts you'll need to run Visual Studio as an administrator
Best Answer
IIS 6 onwards should already do this for you according to this MSDN article:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/9c6405ef-b247-4c0c-b490-41a9b6682b1e.mspx?mfr=true