I wrote a tag that I'd like to share with you in the hopes of getting some feedback and tips for improvement. Read it if you have a moment. Take some time to check the code, and let me know how this can be improved, and whether it's completely thread-safe.
Here's the problem: I have a website with many areas of customization. The header has "Welcome back #name#" and other custom session-based settings. The left nav sometimes has custom items, etc, etc etc.... I want to optimize database activity, and the queries are often large (since there's no way to do a startrow in cfquery on mssql, just a maxrows), so you can't always cache the query in memory via cachedwithin,etc... I'd like to improve performance, but CFCACHE is the wrong approach for session-based pages, since it does't allow customized pages.
Here's the solution: This morning I wrote and tested a solution to my problem. Addressing the issues above, I basically decided to cache parts of pages to files. This way, I can keep the customized parts which use session variables still being processed that way, but the DB intensive areas will read from a file when the cache runs stale. Because CFINCLUDE runs the risk of processing the code, I CFFILE read and cfoutput it to be safe. I choose unique names for my cached "zones" so they are non-overlapping. (in my case, it's a fusebox 2 site, so I use fuseaction combined with page attributes, on a use basis). That's a nice "Feature" that you can have a logical cache, rather than strictly URL based,etc;
-------------------
Where I'm using it: I created and run as a hobby a CF site for listing jewish celebrations called onlysimchas.com.... I put this tag into place on pages which list all photos in galleries, and all announcements of a particular category. It is showing significantly improved performance (The site gets about 250K-300K page views daily, on a dual 933Mhz 1GB server with on-board iis/cfmx6.1/mssql backend)
For example: http://www.onlysimchas.com/galleries/index.cfm?fuseaction=gallerymain&simchatypeid=6
The main DB area (in the center) is wrapped in a <cf_cache_tagoutput key="#attributes.fuseaction#_#attributes.simchaid#_#attributes.startrow#">
Notice in the source code, you will see a "Wrote to" comment tag or a "Read From" comment tag.
Another example: (pictures of my boys) http://www.onlysimchas.com/galleries/index.cfm?fuseaction=viewgallery&SimchaID=12728&galleryID=14211
<cf_cache_tagoutput key="#attributes.fuseaction#_#attributes.simchaid#_#attributes.galleryid#">
TAG BELOW (CLEANED UP A BIT)
---------------------------------------
<!---
Name : CacheTagOutput
Author : Dov Katz
Somewhat Based Upon: cf_scopeCache by Rayomond Camden [http://www.findarticles.com/cf_dls/m0MLU/4_5/99886537/p3/article.jhtml?term=]
Created : Jan 9 2004
Last Updated :
History :
Purpose : Allows you to cache partial page content to files
--->
<!
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

