Expires headers on AppHarbor - appharbor

Is there an easy way to add expires headers to static content coming from an appharbor site? I have a bunch of images, css and javascript files which have no expiry set and are holding me back on yslow.

You can do this in Web.config:
<system.webServer>
<staticContent>
<clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>
</system.webServer>

Related

Cache busting in IIS using query string for static content

my site is a static site and I serve the content from a IIS 8 web server. I used to use Apache and I have the following configuration for cache busting, which I'd like to implement in IIS:
# Extend cache expiry for fingerprinted URLs
RewriteCond %{QUERY_STRING} ^[0-9a-fA-F]{8,}$
RewriteRule ^ - [E=revved:1]
And then I set Cache-Control based on whether the environment variable "revved" is set:
# (For HTTP/1.1 clients)
Header set Cache-Control "max-age=1200" env=!revved
Header set Cache-Control "max-age=31536000" env=revved
My JS and CSS is bundled and I attach the hash to the query string. I do the same for images.
So far what I have been available to do is use the <clientCache /> element and attach cacheControlMode="UseMaxAge and cacheControlMaxAge="00:20:00" to it.
What you can see in the Apache config is that when the "revved" variable is set then the proxy server (CDN) and the client should cache the files for 365 days. Otherwise, it should only cache for 20 minutes. I'd like to have the same behaviour in my web.config.
I read about "Output Caching" in IIS, but from what I understand that is designed for dynamic pages using PHP or ASP.
I would be very grateful, if someone can guide me in the right direction.
I believe that I came up with a solution that is working. I got some hints from this post on MSDN "Change or modify a Response Header value using URL Rewrite".
<outboundRules>
<rule name="ChangeCacheControlHeaderOneYear">
<match serverVariable="RESPONSE_CacheControl" />
<conditions>
<add input="{QUERY_STRING}" pattern="^[0-9a-fA-F]{8,}$" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
<rule name="ChangeCacheControlHeader20Minutes">
<match serverVariable="RESPONSE_CacheControl" />
<conditions>
<add input="{QUERY_STRING}" pattern="^[0-9a-fA-F]{8,}$" negate="true" />
</conditions>
<action type="Rewrite" value="max-age=1200" />
</rule>
</outboundRules>

Response header: Pragma: No-cache

So I've been fiddling around with this for quite a bit now and don't seem to be anywhere near the answer to my problem.
For some reason IE does not cache the static content of my website (img/js) yet Chrome does.
Looking at the headers I found the both the pragma tag, as well as the Cache-control have a no-cache set but I do not know where this thing comes from. No-where in the application the no-cache is ever set.
I am using IIS 7.5 and Oracle WebGate as authenticator.
On our IIS itself, I have set the settings to cache the content and live for 36 hours.
Also in the web.config the following tag is present in the image folder:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
</system.webServer>
Furthermore, I also have a tag in my web.config of my front-end
<caching>
<cache disableExpiration="false" />
</caching>
I read on some forums that removing this would help but alas, it doesn't.
I also looked for add extension because that also seemed to be causing issues according to someone else but I never set something like that.
Has anybody got any idea what this could be causing?
By default Oracle Web Gate uses by default cache control no-cache and pragma no-cache.
see the doc here : http://docs.oracle.com/cd/E22203_01/doc.31/e20664/chapter_12.htm
at the bottom of the page

Cross-Domain redirect after ajax request

i simply need to load a cross-domain asp.net page using jQuery's load() function, but this page can trigger a redirect (i have access to both Server and Client pages).
The loaded page is an asp.net page and i use from server:
Response.Redirect("http://www.google.it")
but chrome cancels the redirect request. I already googled a lot about this and lot of people say "use CORS", i can't because cors are not supported on IE7 and i need to support that browser.
I tried with Custom Headers but seems like i can't read those from a cross domain, even if the server have this in web.config:
<customHeaders>
<add name="Access-Control-Allow-Headers" value="*" />
<add name="Access-Control-Allow-Origin" value="http://10.0.0.158" />
<add name="Access-Control-Allow-Methods" value="*" />
<add name="Access-Control-Allow-Credentials" value="true" />
<add name="Access-Control-Expose-Headers" value="*"/>
</customHeaders>
Yes, http://10.0.0.158 is my local "client page" ip.
After some googling i read about easyXDM libraries but i'm still not sure they can do the trick. Can i use those? How? Have i other alternatives?
Ps: i get the header with this:
jQuery('body').bind('ajaxSuccess',function(event,request,settings){
console.log("ajaxSuccess triggered: "+request.getAllResponseHeaders());
});
and it writes only this:
Content-Type: text/html; charset=utf-8
Cache-Control: private
with fiddler the header is a lot bigger with all my custom headers.

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

How to Leverage browser caching at ASP.net IIS 7.5

The following cacheable resources have a short freshness lifetime. Specify an expiry of at least one week in the future for the following resources:
http://pagespeed.googlelabs.com suggest me this for my website as a high priority. I am using windows server 2008 r2 netframework 4.0 asp.net IIS 7.5 . How do i do this ?
This is the direct url for you to see : http://pagespeed.googlelabs.com/#url=www.monstermmorpg.com&mobile=false&rule=LeverageBrowserCaching
You might start here with this article, also Mads Kristensen had written an interesting blog post on how to compress, minify and cache dynamic and static content on your website.
<configuration>
<location path="showStockPrice.asp">
<system.webserver>
<caching>
<profiles>
<add varybyquerystring="*"location="Any"
duration="00:00:01" policy="CacheForTimePeriod"
extension=".asp">
</profiles>
</caching>
</system.webserver>
</location>
To cache static content
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00"/>
</staticContent>

Resources