Disable browser cache for entire ASP.NET website

Create a class that inherits from IActionFilter. public class NoCacheAttribute : ActionFilterAttribute { public override void OnResultExecuting(ResultExecutingContext filterContext) { filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false); filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); filterContext.HttpContext.Response.Cache.SetNoStore(); base.OnResultExecuting(filterContext); } } Then put attributes where needed… [NoCache] [HandleError] public class AccountController : Controller { [NoCache] [Authorize] public ActionResult ChangePassword() { return View(); } }

Force browser to clear cache

If this is about .css and .js changes, one way is to to “cache busting” is by appending something like “_versionNo” to the file name for each release. For example: script_1.0.css // This is the URL for release 1.0 script_1.1.css // This is the URL for release 1.1 script_1.2.css // etc. Or alternatively do it … Read more

How can I force clients to refresh JavaScript files?

As far as I know a common solution is to add a ?<version> to the script’s src link. For instance: <script type=”text/javascript” src=”https://stackoverflow.com/questions/32414/myfile.js?1500″></script> I assume at this point that there isn’t a better way than find-replace to increment these “version numbers” in all of the script tags? You might have a version control system do … Read more

How to Empty Caches and Clean All Targets Xcode 4 and later

Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData manually. Remove all its contents because there’s a bug where Xcode will run an old version of your project that’s in there somewhere. (Xcode 4.2 will show you the Derived Data folder: choose Window > Organizer and switch to the … Read more

Read whole ASCII file into C++ std::string [duplicate]

There are a couple of possibilities. One I like uses a stringstream as a go-between: std::ifstream t(“file.txt”); std::stringstream buffer; buffer << t.rdbuf(); Now the contents of “file.txt” are available in a string as buffer.str(). Another possibility (though I certainly don’t like it as well) is much more like your original: std::ifstream t(“file.txt”); t.seekg(0, std::ios::end); size_t … Read more

What’s with the integer cache maintained by the interpreter?

Python caches integers in the range [-5, 256], so integers in that range are usually but not always identical. What you see for 257 is the Python compiler optimizing identical literals when compiled in the same code object. When typing in the Python shell each line is a completely different statement, parsed and compiled separately, … Read more