Stephen Forte's Blog

 RSS/Feedburner
      Home     Steve & The Tank       

  Sunday, January 11, 2004

     How the das Blog Cache Engine Works (And a Caching tip in General)

How the das Blog Cache Engine Works (And a Caching tip in General)

 

Clemens and I may disagree on SQL Server v XML storage, but the das Blog Cache engine is real simple and we agree on it. What we do is cache the main page for 1 day (86400 seconds). We also varybyparam for the date and none. This way the page will stay in cache for either 1 day or until it is edited again (via a comment or an addition blog entry.)

 

I was putting together some samples for the MDC in Cairo next week and made a real simple page that caches a page based on the query string (varybyparam) and a file dependency (an XML file).  Here is an example in a simple page using an ASP .NET datagrid against Northwind:

 

<%@ Page language="c#" Codebehind="Cache_VaryByParam_Filedep.aspx.cs" AutoEventWireup="false" Inherits="DataGridCSharp.CachingDataGridFile" %>

<%@ OutputCache duration="86400" varybyparam="CustomerID" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>CachingDataGrid</title>

<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">

<meta name="CODE_LANGUAGE" Content="C#">

<meta name="vs_defaultClientScript" content="JavaScript">

<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

</HEAD>

<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 72px" runat="server"></asp:DataGrid>

<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 24px; POSITION: absolute; TOP: 40px" runat="server"

                   Width="440px">Label</asp:Label>

</form>

</body>

</HTML>

 

 

Then all we do is add a file dependency, in the case of das Blog it is the actual XML file that stores the data. This way the page will stay in cache for either 1 day or until it is edited again (via a comment or an addition blog entry.) Here is the code behind for the simple Northwind example from above.

 

          private void Page_Load(object sender, System.EventArgs e)

          {

              //we are setting the OutputCache to 1 day and the varybyparam for the querystring

              //<%@ OutputCache duration="86400" varybyparam="CustomerID" %>       

              //override the cache if this file changes

              Response.AddFileDependency(Server.MapPath("Contacts.xml"));

             

              Label1.Text="Page Generated At: " + System.DateTime.Now.ToString();

              // simple databinding for testing

              SqlConnection conn =new SqlConnection("server=(local);uid=sa;pwd=;database=Northwind");

              //open the connection

              conn.Open();

              //can set a command to a SQL text and connection

SqlCommand cmd = new SqlCommand("Select * From Orders Where CustomerID='" + Request.QueryString["CustomerID"] +"'", conn);

              SqlDataReader dr;

    

              //open a datareader

              dr = cmd.ExecuteReader(CommandBehavior.Default);

 

              //do the databinding

              DataGrid1.DataSource = dr;

              DataGrid1.DataBind();

          }



Speaking

Sunday, January 11, 2004 11:36:27 PM (Eastern Standard Time, UTC-05:00)
Comments [0]  |  Trackback Related posts:
Data Access Smackdown Preview
Walking on Fire or Don’t Drink with Serbians (European Tour Update)
See me on Channel 9
Techdays 2008
October 23rd New York IASA Meeting
DevReach 2007 Conference (Bulgaria)
Tracked by:
"http://morningside.edu/mics/_notes/pages/melatonin/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/ultram/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/clomid/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/melatonin/index.html" (http://blastpr.com/wiki... [Pingback]
"http://morningside.edu/mics/_notes/pages/effexor/index.html" (http://morningsid... [Pingback]
"http://blastpr.com/wiki/js/pages/prozac/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/synthroid/index.html" (http://blastpr.com/wiki... [Pingback]
"http://blastpr.com/wiki/js/pages/coumadin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/nexium/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/soma/index.html" (http://morningside.e... [Pingback]
"http://blastpr.com/wiki/js/pages/prilosec/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/synthroid/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/cymbalta/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/lipitor/index.html" (http://morningsid... [Pingback]
"http://blastpr.com/wiki/js/pages/soma/index.html" (http://blastpr.com/wiki/js/p... [Pingback]
"http://blastpr.com/wiki/js/pages/tramadol/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/wellbutrin/index.html" (http://blastpr.com/wik... [Pingback]
"http://morningside.edu/mics/_notes/pages/prilosec/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/viagra/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/paxil/index.html" (http://blastpr.com/wiki/js/... [Pingback]
"http://morningside.edu/mics/_notes/pages/clomid/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/claritin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/lipitor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://morningside.edu/mics/_notes/pages/rainbow-brite/index.html" (http://morn... [Pingback]
"http://blastpr.com/wiki/js/pages/celexa/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/zoloft/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/coumadin/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/celexa/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/wellbutrin/index.html" (http://morning... [Pingback]
"http://blastpr.com/wiki/js/pages/effexor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://morningside.edu/mics/_notes/pages/viagra/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/lexapro/index.html" (http://morningsid... [Pingback]
"http://blastpr.com/wiki/js/pages/rainbow-brite/index.html" (http://blastpr.com/... [Pingback]
"http://morningside.edu/mics/_notes/pages/tramadol/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/accutane/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/hoodia/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/nexium/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/cymbalta/index.html" (http://morningsi... [Pingback]
"http://realestate.hr/templates/css/docs/36157459/index.html" (http://realestate... [Pingback]
"http://swellhead.netswellhead.net/docs/92808772/index.html" (http://swellhead.n... [Pingback]
"http://temerav.com/images/menu/20420171/index.html" (http://temerav.com/images/... [Pingback]
"http://ipsilon.hr/ipsilon.hr/cms/4/lib/docs/55227677/index.html" (http://ipsilo... [Pingback]
"http://blog.netmedia.hr/wp-includes/js/docs/44378735/index.html" (http://blog.n... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/86309858/index.html" (http://vlada... [Pingback]
"http://swellhead.netswellhead.net/docs/84545083/index.html" (http://swellhead.n... [Pingback]
"http://add2rss.com/img/design/docs/45658867/index.html" (http://add2rss.com/img... [Pingback]
"http://martinrozon.com/images/photos/docs/56637999/index.html" (http://martinro... [Pingback]
"http://swellhead.netswellhead.net/docs/79619129/index.html" (http://swellhead.n... [Pingback]
"http://plantmol.com/docs/80639343/index.html" (http://plantmol.com/docs/8063934... [Pingback]
"http://discussgod.com/cpstyles/docs/25383456/index.html" (http://discussgod.com... [Pingback]
"http://realestate.hr/templates/css/docs/28593877/index.html" (http://realestate... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/54089144/index.h... [Pingback]
"http://seo4u.at/images/docs/76783685/index.html" (http://seo4u.at/images/docs/7... [Pingback]
"http://thebix.com/includes/compat/docs/10152421/index.html" (http://thebix.com/... [Pingback]
"http://martinrozon.com/images/photos/docs/43274485/index.html" (http://martinro... [Pingback]
"http://legambitdufou.org/Library/docs/28049195/index.html" (http://legambitdufo... [Pingback]
"http://legambitdufou.org/Library/docs/64933533/index.html" (http://legambitdufo... [Pingback]
"http://witze-humor.de/templates/images/docs/69259068/index.html" (http://witze-... [Pingback]
"http://coolioness.com/attachments/docs/76375390/index.html" (http://coolioness.... [Pingback]
"http://temerav.com/images/menu/05559064/index.html" (http://temerav.com/images/... [Pingback]
"http://pspdesktops.com/fileupload/store/docs/33460308/index.html" (http://pspde... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/68291686/index.h... [Pingback]
"http://pddownloads.com/docs/66275653/index.html" (http://pddownloads.com/docs/6... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/37348396/index.html" ... [Pingback]
"http://thebix.com/includes/compat/docs/51589391/index.html" (http://thebix.com/... [Pingback]
"http://slaterjohn.com/downloads/2col/51579700/index.html" (http://slaterjohn.co... [Pingback]
"http://plantmol.com/docs/60217277/index.html" (http://plantmol.com/docs/6021727... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/60974094/index.h... [Pingback]
"http://allfreefilms.com/wp-includes/js/46226552/index.html" (http://allfreefilm... [Pingback]
"http://entartistes.ca/images/images/docs/28212733/index.html" (http://entartist... [Pingback]
"http://realestate.hr/templates/css/docs/71546796/index.html" (http://realestate... [Pingback]
"http://discussgod.com/cpstyles/docs/43932298/index.html" (http://discussgod.com... [Pingback]
"http://split-dalmatia.com/split-dalmatia.com/images/docs/84431573/index.html" (... [Pingback]
"http://coolioness.com/attachments/docs/58150246/index.html" (http://coolioness.... [Pingback]
"http://entartistes.ca/images/images/docs/81367526/index.html" (http://entartist... [Pingback]
"http://thejohnslater.com/pix/img/docs/86193101/index.html" (http://thejohnslate... [Pingback]
"http://pspdesktops.com/fileupload/store/docs/04061117/index.html" (http://pspde... [Pingback]
"http://split-dalmatia.com/split-dalmatia.com/images/docs/16705258/index.html" (... [Pingback]
"http://jivest2006.com/docs/42940613/index.html" (http://jivest2006.com/docs/429... [Pingback]
"http://thebix.com/includes/compat/docs/29852280/index.html" (http://thebix.com/... [Pingback]
"http://thebix.com/includes/compat/docs/15132509/index.html" (http://thebix.com/... [Pingback]
"http://martinrozon.com/images/photos/docs/75270452/index.html" (http://martinro... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/52060005/index.html" ... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/36483653/index.html" ... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/82710340/index.h... [Pingback]
"http://ipsilon.hr/ipsilon.hr/cms/4/lib/docs/24066563/index.html" (http://ipsilo... [Pingback]
"http://sevainc.com/bad_denise/img/5/effexor/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://easytravelcanada.info/js/pages/2/celexa/" (http://easytravelcanada.info/... [Pingback]
"http://sevainc.com/bad_denise/img/12/viagra/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://easytravelcanada.info/js/pages/8/prilosec/" (http://easytravelcanada.inf... [Pingback]
"http://easytravelcanada.info/js/pages/9/prozac/" (http://easytravelcanada.info/... [Pingback]
"http://easycanada.info/js/pages/cialis/" (http://easycanada.info/js/pages/ciali... [Pingback]
"http://easymexico.info/images/img/cialis/" (http://easymexico.info/images/img/c... [Pingback]
"http://easytravelcanada.info/js/pages/11/tramadol/" (http://easytravelcanada.in... [Pingback]
"http://easytravelcanada.info/js/pages/10/soma/" (http://easytravelcanada.info/j... [Pingback]
"http://easytravelcanada.info/js/pages/7/nexium/" (http://easytravelcanada.info/... [Pingback]
"http://easytravelcanada.info/js/pages/11/ultram/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/4/cymbalta/" (http://sevainc.com/bad_denise/i... [Pingback]
"abaffy.org/la/img/viagra/" (abaffy.org/la/img/viagra/) [Pingback]
"http://abaffydesign.com/la/img/viagra/" (http://abaffydesign.com/la/img/viagra/... [Pingback]
"http://ina-tv.sk/img/cialis/" (http://ina-tv.sk/img/cialis/) [Pingback]
"http://sevainc.com/bad_denise/img/12/zoloft/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://easytravelcanada.info/js/pages/1/celebrex/" (http://easytravelcanada.inf... [Pingback]
"http://sevainc.com/bad_denise/img/7/melatonin/" (http://sevainc.com/bad_denise/... [Pingback]
"http://easytravelcanada.info/js/pages/12/viagra/" (http://easytravelcanada.info... [Pingback]
"http://jemnemelodierecords.sk/img/cialis/" (http://jemnemelodierecords.sk/img/c... [Pingback]
"http://easytravelcanada.info/js/pages/6/lipitor/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/11/ultram/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://easytravelcanada.info/js/pages/7/melatonin/" (http://easytravelcanada.in... [Pingback]
"http://adventure-traveling.com/images/img/viagra/" (http://adventure-traveling.... [Pingback]
"http://easytravelcanada.info/js/pages/12/wellbutrin/" (http://easytravelcanada.... [Pingback]
"http://sevainc.com/bad_denise/img/2/cialis/" (http://sevainc.com/bad_denise/img... [Pingback]
"abaffy.org/la/img/cialis/" (abaffy.org/la/img/cialis/) [Pingback]
"http://sevainc.com/bad_denise/img/2/celexa/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://easytravelcanada.info/js/pages/3/clomid/" (http://easytravelcanada.info/... [Pingback]
"http://sevainc.com/bad_denise/img/8/prilosec/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://easytravelcanada.info/js/pages/5/effexor/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/11/tramadol/" (http://sevainc.com/bad_denise/... [Pingback]
"http://abaffydesign.com/la/img/cialis/" (http://abaffydesign.com/la/img/cialis/... [Pingback]
"http://sevainc.com/bad_denise/img/9/prozac/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://birds.sk/img/viagra/" (http://birds.sk/img/viagra/) [Pingback]
"http://easytravelcanada.info/js/pages/6/lexapro/" (http://easytravelcanada.info... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/foot-fetish-video-s.html" ... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/nude-celeb-thumbs.html" (... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/animal-sex-bondage.html" (... [Pingback]
"http://odin.net/images/pages/52807681/free-unlimited-ipod-porn.html" (http://od... [Pingback]
"http://odin.net/images/pages/52807681/red-hot-chilli-peppers-tell-me-baby.html"... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/dress-up-online-games-for-... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/anime-preteen-sex.html" (... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/erotic-literature-for-wome... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/celebrities-sexy-pictures... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/porn-vagina-sex.html" (ht... [Pingback]
"http://odin.net/images/pages/35694472/lightspeed-teens.html" (http://odin.net/i... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/sexual-world-records.html"... [Pingback]
"http://odin.net/images/pages/35694472/lesbian-simpsons.html" (http://odin.net/i... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/spanish-escorts-es.html" (... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/pics-of-sexy-women-in-wes... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/the-internet-is-for-porn.... [Pingback]
"http://odin.net/images/pages/35694472/baby-got-back-by-throwdown.html" (http://... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/jacqueline-teen-model-is-... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/what-is-the-mature-ripene... [Pingback]
"http://odin.net/images/pages/35694472/babe-tv.html" (http://odin.net/images/pag... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/taylor-hayes-free-pics.ht... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/teen-doggystyle-fucking-f... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/federal-judge-sex-scandal-... [Pingback]
"http://odin.net/images/pages/35694472/danni-hunt-in-nude.html" (http://odin.net... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/porn-postcards-free.html" ... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/baby-pool.html" (http://ci... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/tylene-buck-bikini-movies... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/little-match-girl-story.h... [Pingback]
"http://odin.net/images/pages/52807681/erotic-slavery-stories.html" (http://odin... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/free-mature-bbw-porn.html... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/ametuer-zoo-girls.html" (... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/mother-and-daugther-sex-s... [Pingback]
"http://odin.net/images/pages/35694472/gay-justin-berfield.html" (http://odin.ne... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/preview-girls-gone-wild-cl... [Pingback]
"http://odin.net/images/pages/35694472/sexy-happy-birthday-girls.html" (http://o... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/ravon-nude.html" (http://... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/camping-naturisten-free-p... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/free-pictures-of-amateur-p... [Pingback]
"http://odin.net/images/pages/52807681/charleston-swingers.html" (http://odin.ne... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/fuck-bitches-get-money-lyr... [Pingback]
"http://odin.net/images/pages/35694472/thumbs-of-squirting-babes.html" (http://o... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/free-erotic-lesbian-video... [Pingback]
"http://odin.net/images/pages/35694472/candace-von-fuck.html" (http://odin.net/i... [Pingback]
"http://odin.net/images/pages/35694472/mature-chat.html" (http://odin.net/images... [Pingback]
"http://odin.net/images/pages/52807681/ymca-baby-sitting-classes.html" (http://o... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/sexual-protective-strategi... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/fucking-icons.html" (http:... [Pingback]
"http://odin.net/images/pages/52807681/life-teen-mass-balboa.html" (http://odin.... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/i-need-free-party-ideas-fo... [Pingback]
"http://odin.net/images/pages/52807681/sexy-co-eds.html" (http://odin.net/images... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/stories-of-kakashi-and-sa... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/britney-spears-nude-crotc... [Pingback]












newtelligence dasBlog 2.0.7226.0

Copyright © 2008 Stephen Forte. Available under the Creative Commons Attribution 3.0 License.

 The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way