Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:53:45+00:00 2026-05-31T07:53:45+00:00

I have a single-page JavaScript application, held within an ASP.NET MVC 3 website. In

  • 0

I have a single-page JavaScript application, held within an ASP.NET MVC 3 website.

In order to cache-bust the JS/CSS files used by the application, without the need for manually renaming files each time a change is made, I have the following routes & respective controller actions for serving static files.

Global.asax.cs

routes.MapRoute(
    "AppCssFile",
    "style.{version}.min.css",
    new { controller = "StaticFile", action = "CssFile" }
);

routes.MapRoute(
    "AppJsFile",
    "app.{version}.min.js",
    new { controller = "StaticFile", action = "JsFile" }
);

StaticFileController

//NB: m_JsAppFolder references below just point to the root folder for static files

[HttpGet]
public FileResult CssFile()
{
    var sourceFile = HttpContext.Server.MapPath(Path.Combine(m_JsAppFolder, "assets", "style", "release.css"));
    return new FilePathResult(sourceFile, "text/css");
}

[HttpGet]
public FileResult JsFile()
{
    var sourceFile = HttpContext.Server.MapPath(Path.Combine(m_JsAppFolder, "release.js"));
    return new FilePathResult(sourceFile, "text/javascript");
}

This works well, however the problem is that my Cache-Control header does not return the value I would expect…

As I have the following in my Web.config:

...
<urlCompression doStaticCompression="true" />
<staticContent>
    <!-- Set expire headers to 1 year for static content-->
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
<!-- use utf-8 encoding for anything served text/plain or text/html -->
<remove fileExtension=".css" />
<mimeMap fileExtension=".css" mimeType="text/css" />
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript" />
</staticContent>
...

I would expect to see a Cache-Control header of Cache-Control:public,max-age=31536000, in the same as if the CSS/JS files were referenced directly, rather than via a Controller Action.

Is there anyway to get MVC to treat a controller action response as staticContent: I don’t really want to have to manually set the Cache-Control header in my controller, as this would mean that both this setting and that in the Web.config could get out of sync.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:53:46+00:00Added an answer on May 31, 2026 at 7:53 am

    Are you looking for the OutputCacheAttribute?

    With this you can have your result cache in the server and the client using the properties Duration and Location.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET Site that has a single Master Page. On one of
I have an ASP.NET 3.5sp1 app that is a single page design. The site
I have a struts2 application with a single page that may show one of
I have modified a website with a redirection to a single page: RewriteCond %{REQUEST_FILENAME}
Here's what i have : ASP.NET 4.0 Web Application Forms Authentication (Cookie Based) Here's
I want all of the validators in an ASP.Net 3.5 website to have a
I've been looking to use Google Analytics _gaq.push() function on a single-page JavaScript application
We have a single page application which loads all content through ajax calls to
Have you experimented with single page web application, i.e. where the browser only 'GETs'
Here's what I have: A web application that runs in a single HTML page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.