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 302743
In Process

The Archive Base Latest Questions

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

In IIS7 I am trying to set a really far future expires header for

  • 0

In IIS7 I am trying to set a really far future expires header for all content that have the file name that has a specific word in it. For example I would like to set this header on any file being requested from IIS7 that is

*cached*.js

I know that it is possible to set far future expires headers, But I want to know if it is possible to set it on specific files like in the example above.

I want to use this method on a .NET application I am trying to serve up, but I want to make it more efficient so that certain files will be cached for a very long time, because it virtually never changes. At the same time I don’t want to be restricted to doing it for all files in a certain folder or all files of certain type.

I am open to doing this through modifying my Asp.Net application to achieve this, or through IIS7 settings.

So guys, what do you think, is There a way to do this?

  • 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-12T07:07:31+00:00Added an answer on May 12, 2026 at 7:07 am

    An HttpModule will let you do this. That would let you look at the incoming URL then add the correct response headers.

    Edit: Added Example

    You can use this URL to create a basic HttpModule. Then in the Application_BeginRequest event, I think this code will be close to what you want:

    if (context.Request.FilePath.ToLower().IndexOf("cached") != -1)
        context.Response.Cache.SetExpires(DateTime.Now.AddYears(1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a virtual directory and set it's permissions using IIS7
I really like the IIS7 URL rewriting module and so far, it worked great
I'm trying to host a WCF service in IIS7 that works with both Silverlight
I'm trying to set up forms authentication across multiple servers and subdomains. I have
I have a method that runs executes a batch file. This worked until I
I have a build that I am trying to do in TFS2010 (server 2008R2)
I am trying to set up IIS7 so the a URL with the pattern:
I trying create iis7 web application by msbuild community tasks and set property Enabled
I've got IIS7.5 running, and I'm trying to match an explicit URL. The following
I'm having a bit of a play around with IIS7, just trying to catch

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.