/ Published in: ASP
Code snippet prevents caching of the page by setting http header values and a LAST MODIFIED header to prevent google from caching too long. This should go into the page load event.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//prevent browsers from caching the page. Response.Cache.SetCacheability(HttpCacheability.NoCache); #region Google cache fix (prevents google from cachine the page too long) System.IO.FileInfo currentInfo = new System.IO.FileInfo(Request.PhysicalApplicationPath); System.IO.FileInfo currentDirInfo = new System.IO.FileInfo(Request.PhysicalPath); DateTime modifiedTimeToUse; if (currentInfo.LastWriteTime > currentDirInfo.LastWriteTime) modifiedTimeToUse = currentInfo.LastWriteTime; else modifiedTimeToUse = currentDirInfo.LastWriteTime; Response.AppendHeader("Last-Modified", modifiedTimeToUse.ToString("ddd, dd MMM yyyy hh:mm:ss GMT")); #endregion