How to set cache expiry date - performance

Trying to cache a large js file on the client browser. When I check firefox's cache information, it shows the js to expire on 12/31/1969. I'm using IIS6 and have tried adding the following code to the web.config:
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
Still the same. How can I get the browser to cache this file?

In IIS, right click on your Site node and click Properties. Go to the HTTP Headers tab, tick Enable content expiration and set an expiry time.

You may have to configure that in IIS, I'm not sure that IIS6 honors that web.config setting like IIS7 does.

Related

enabling caching of js/css files with nodejs/iis7 reverse proxy

I have a nodejs backend, site served through iis7 via reverse proxy as per this website: https://alex.domenici.net/archive/deploying-a-node-js-application-on-windows-iis-using-a-reverse-proxy. In the node app i have a middleware layer to all get requests to cache content, like so
res.set('Cache-control', public, max-age=${period})
When running on my local machine i'm checking the headers via google developer tools and it does look like caching is working properly. When I move it to production, i can't seem get it to work. On IIS i've configured the HTTP Response Headers to expire after 10 days. My web.config looks like so (again per the link above)
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00"/>
</staticContent>
</system.webServer> </configuration>
Tried various things without success. The only possible lead i have at this point is from this thread
https://social.msdn.microsoft.com/Forums/vstudio/en-US/981bf691-ed6e-460a-9e99-af24fc8bfc0e/nodejsweb-apps-output-cache-not-working-for-node-web-app?forum=opensourcedevwithazure
but i have no idea how to make the suggested change in the web.config file. A couple of notes, im currently just running my node app in the command prompt like so: node app.js, not as node bin/www as suggested in the link (having some odd issues). Also, the site is still very much in development so on ssl. Read that chrome might have some issues with it, but the problem is present in all browser tested (chrome, firefox, etc...)

IIS 10 response headers keep reverting after publishing from Visual Studio 2015

I follow something similar to these steps to add CORs to IIS 10 and after about 10 minutes, the response header is removed and CORs stops working.
Open Internet Information Service (IIS) Manager.
Right click the site you want to enable CORS for and go to Properties.
Change to the HTTP Headers tab.
In the Custom HTTP headers section, click Add.
Enter Access-Control-Allow-Origin as the header name.
Enter * as the header value.
Click Ok twice.
Then I go back to Visual Studio and publish my project. Why are my CORs response headers being removed and how do I make them stay?
Thanks to a strong hint from S. Walker, I went onto the server, modified the response header as desired and then looked at the web.config file.
It had added:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
So I copied that into my project web.config file and published. Now it doesn't disappear and CORs continues to work. Seems obvious now.

"Leverage browser caching" not working in IIS or Page Speed reporting wrong

I have tried set this in web.config:
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
I also modified the value through the GUI but my Response Headers still says no-cache:
I read several posts and this one looked promising but still I can't get it to work.
From what I understand from this image the image bbb.png is taken from the cache but Page Speed (after refresh, and after waiting a couple of minutes) that it still is not being cashed:
Why isn't this working?
According to https://varvy.com/pagespeed/ I'm not caching 3rd party images:

Updating clientCache in web config not changing expires header

I have a site running on iis7.5 where, through Firebug, I can see that my static content (css, js and images) have an expiration in their header consistently set to one day in the future. I find no where this is set, but I just came on recently to the project.
I want to make the expiration further in the future, so added a section in the web.config:
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="100.00:00:00" />
</staticContent>
</system.webServer>
After restarting the site, this had no affect on the expiration date of these items.
My question is, what can override the clientCache setting, imposing a different expiration date?
Thanks,
Matt

Website default document denied by security restrictions?

I have an ASP.Net 4.0 website hosted at winhost.com.
The default document is index.html. In the browser address bar, if I enter
http://www.mysite.com/index.html
it works fine - I get the index.html page as desired.
If, however, I simply enter http://www.mysite.com
the site behaves as if I have requested a page allowed only to authenticated users, that is, I am automatically redirected to the Login.aspx page.
Obviously this is a major panic! It means that the normal, public facing portion of the site is no longer visible unless visitors are instructed to include "index.html".
In IIS, I have verified that the "Default Document" is index.html, and it is first in the list.
In the web.config, I tried adding
<location path="index.html">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
But that did not help.
This all happened when I converted the site from 2.0 to 4.0. I was so busy fixing all the other problems (ajax security, wrong versions of dlls, etc.) that I never noticed this problem. Seems like it should be simple to fix, but I am stumped. Thanks for any help!
Check the NTFS permissions for the folder, where your website is located. And compare it with "index.htm" file permissions. Some user account must be missing.

Resources