So it's been a week since my last post. That's pretty bad - I made a rule for myself that I'd post at least once every 2 working days. Guess I didn't have anything of note. So what have I been up to? Advanced caching for one thing...
Last Monday I decided to finally get around to adding content-caching to the Digital Crew site engine. With proper advanced caching, a single server could host up to 10 times the amount of websites, leading to cost savings and an overall improvement in website speeds. So I pulled out my old dcCache tag. I then re-factored (to use some bullshitty programming jargon) the tag bringing the code into the CFMX age. The tag works like so:
<dcCom component="dcCache" key="stuff"> CONTENT HERE </dcCom>
If the tag detects a cached version of "stuff", it just loads up that HTML page and spits it out, then exits the tag using <cfexit method="exittag">.
By the way, I had an old note in the tag saying that there was a bug with <cfexit> in which if the exittag option was called, it would still execute the content nested with the tag. I tested and this bug seems to be gone so I reimplemented the <cfexit> code.
This tag is used to cache various items around a web page. A "Top 10 Movies" content snippet could be cached for example so that it only updates when the database behind it is updated saving the execution of a query and parsing of result on every page of the site. Also an entire page could be cached. That entire page might contain the "Top 10 Movies" cached item. I got thinking about this and wanted a way so that if the "Top 10 Movies" snippet is reset, the parent cached item, the full page in this example is also reset.... I won't bored you with the details but with a REQUEST.dcCacheCurrentList variable I was able to make this magic happen.
I'm a little concerned that repeated loading the cached content from disk might be slow - it might be better to cache the most popular content in memory, but then again the operating system should know that certain disk items are being repeated accessed and make them easily available.
To reset the cache, the dcCache component is called using
<dcCom component="dcCache" action="resetlist" resetList="Top10Movies">
I used all this caching milarchy for Digital Warehouse and after some teething problem, the site now seems to be nice and fast - it's basically just spitting out pre-rendered HTML code for 90% of the web page. That's the beauty of dcCache, it can be used for just parts of a web page.
In our implementation of www.digitalwarehouse.ie, the CMS is one application and the website is another so I use CFHTTP to send a request from one app to the other to reset items when an update is made in the CMS. So far, it works pretty well. Anyone have a better idea for inter-application communication than CFHTTP and I don't want to hear about using SERVER variables - that's a no-no on a server that could host hundred of sites. :D
Oops, this post is way too long. Way to rant. I was going to give an overview of my entire week but that explanation of one days work has done me in. Stay tuned for another post later today.