I am serving Javascript vai a controller method that looks like this:
[OutputCache(Duration = 120)]
[Compress]
public ActionResult JavascriptFile(String scriptName) {
string content;
if (HttpContext.IsDebuggingEnabled) {
content = ReadApplicationScript(string.Format("~/scripts/{0}", scriptName));
return Content(content, "application/javascript");
}
else {
content = ReadApplicationScript(string.Format("~/scripts/Built/{0}", scriptName));
return Content(content, "application/javascript");
}
}
The Compress
attribute is from here.
When I run ySlow I get an F grade on "Add Expires headers". What can I do to add these?
Add the following inside system.webServer section
Here the httpExpires value will be the expiration date.
Edit
You can also try adding the content to cache like this: