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

  • SEARCH
  • Home
  • 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 7534497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:02:03+00:00 2026-05-30T06:02:03+00:00

I need to clear the IIS cache on my server. The exact reason is

  • 0

I need to clear the IIS cache on my server. The exact reason is detailed below; but the reason doesn’t matter. I’m 100% sure that this is the solution I need; as detailed below, I have used the process of elimination to determine that this is, indeed, the problem I’m facing, and the solution I need.


I have an MVC3 app that’s themeable (skinnable architecture). Think of it as WordPress; users can develop a theme, download it, and activate it on their site. The theme controls exactly the final HTML output. This is an over-simplification, since I provide an API with useful functions to be consumed by themes.

Anyway, users can change the theme of the site. The theme is currently stored in a static variable. When a view page is rendered, the name of the theme determines the location of the layout file (which contains references to the CSS files, etc.) and the view files. The theme is a setting that persists in the DB.

For example, if I have a theme called “Foo”, then when requesting the /Admin page, I might use /Themes/Foo/Admin.cshtml. If I have another theme called “Bar” which does not have that file, then for /Admin it might request /Themes/Bar/Generic.cshtml as the layout.

The problem is that changing a theme means that every single page on the site is outdated. This means that any sites cached on IIS7 will show the old theme; this is incorrect. I need them to show the new theme.

Anyway, IIS7 uses caching by default. I need essentially a way to clear the cache when a user changes the theme. Currently, this is not happening, and users continue to see the old theme until the cache (somehow) expires itself.

I am not using output caching, or any other form of explicit caching; this is a “vanilla” ASP.NET MVC3 application from a caching perspective (i.e. I didn’t add/configure any caching). IIS7 has its own default caching. I know this, because if I disable output caching in IIS7 for my Site, I will always see the correct theme after a change.

How can I flush the cache? Other SO questions point to using Cache.blah, and I tried using HttpContext.Current but that is null during tests (using VS test tool) — because the ASP.NET pipeline is not used in full.

To explain, in an integration test, I basically:

  • Go to localhost/Test/
  • Log in (submit values into the forms)
  • Change the theme by browsing to the right page and clicking the right link
  • Request another page
  • See if the theme changed (based on the layout/css file name).

This is all done by code; I use a C# port of HtmlUnit, and along with deploying my app to /Test in IIS, I can essentially browse it like an end user.

Currently, this test passes around 50% of the time. The problem is that IIS is caching the results, and I can’t cleanly reliably reset the cache on the server-side.

Again, I’m not talking about clearing the session or the user-side cache; IIS itself is the culprit guilty of caching my application. Nor do I want to completely disable the cache via the IIS settings, a) because I can’t force people who install my application to do that, and b) because caching is good.

So how can I force flushing the cache on the server?

For example, I tried programatically touching web.config; this works, but recycles my application pool, and so, kills my static variables; every request means reloading all the static vars from the DB, which kills my performance.

  • 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-30T06:02:05+00:00Added an answer on May 30, 2026 at 6:02 am

    Just touch web.config. That’s the easiest and most reliable way. Flushing the application pool programmatically is overkill.

    If you have a problem finding out where web.config is in a test environment (since System.Web.HttpRequest.Current is null, and similar for Server), you can always use an app.config file to point out the location.

    Again, there’s no other easy way to do it; even disabling output caching, as mentioned in the question, is hard to do through web.config alone.

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

Sidebar

Related Questions

I need to clear all APC cache entries when I deploy a new version
I need to clear the default values from input fields using js, but all
I need to clear many tables (preferably truncate table). But tables have many FK
When we put _stdcall (the caller doesn't need to clear the stack) in the
I just need to clear all the actors added to the table_layout. So that
I need to clear the read-only flag of a file in my Perl program
I had a requirement where I need to clear off the select all checkbox
I need a very simple and clear example of how to create an OCX
Do I need to release a Core Foundation objects to clear up memory? And
It's not clear to me if the Eclipse plugin completely replaces the need to

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.