I set up an RSS page intending that it would cache, only regenerating and hitting the DB once every 5 minutes. But the DB update is running on every refresh - as indicated by the changed lastBuildDate on each refresh: http://www.calcatholic.com/rss/newsfeed.aspx I created a simple demo of the problem. This page often does cache, but still often does not - keep refreshing and see: http://www.calcatholic.com/rss/cachetest.aspx FULL SOURCE OF DEMO IS BELOW - I left in the same using and a query string process to closely match the actual page. On one hand I don't care - more DB traffic is "free" - on the other hand I was trying to design with respect for CPU load on a shared server - and ideas? CACHETEST.ASPX: <%@ Page Language="C#" CodeFile="cachetest.aspx.cs" Inherits="newsfeed" EnableViewState="false" %> <%@ OutputCache Duration="300" VaryByParam="lang;daysback;cat" %> CACHETEST.ASPX.CS: using System; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Text; using System.Web; using System.Xml; public partial class newsfeed : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string pLang = string.Empty; object ol = Request.QueryString["lang"]; if (ol != null) { pLang = ol.ToString(); } else { pLang = "en"; } Response.Write("<html><h1>Cache Test: " + DateTime.Now.ToString()+ "</h1>\n"); for (int i = 0; i < 300; i++) Response.Write("<li>Just adding some content ....." + DateTime.Now.ToString() + "\n"); Response.Write("</body></html>\n"); } }
I was trying to replicate your problem but was unable to do so.I used exactly your code w/ 10s as my cache duration: Link: http://daspstaff00.web120.discountasp.net/error/Default.aspx Everything seems to work fine. Vikram DiscountASP.NET www.DiscountASP.NET
Vikram, Yes, I don't see it consistently on the test case, but refreshing here you see that the cache is not working, causing a DB hit every time: http://www.calcatholic.com/rss/newsfeed.aspx The only difference between the cachetest is that it calls a function the does a query and then writes out objXML instead of calling the Response.Write(). I don't want to paste that code in the forum, but you may examine it on my server, or I can email it to you as a zip. (This is not causing a problem, so set the priority accordingly.) Thanks, Kim