I was thinking that I'd love to have some sort of idea how many people are subscribed to this site.
The Solution
Solution 1: Some people suggest using a HTTP 301 Moved Permanently header to redirect RSS Readers to a unique URL that you can use to track the feed.
Solution 2: Others recommend that you display/make-available a unique RSS feed URL every time you display your blog.
The Problem
The problem with solution 1 is that RSS readers *should* remember that the page is permanently redirected - if they don't you'll get users always being redirected to unique URLs looking like unique subscribers all-the-time.
The problem with solution 2 is that it doesn't track your existing subscribers.
What I Decided to Do
I decided to combine both solutions and hope that there aren't too many stupid RSS readers out there. Now, If you browse to to rss/ you will be redirected to a unique URL.
Also when you view this page, both the RSS feed in the header and the feed displayed on the right hand side are unique.
The Code (in Brief)
For the redirect if URL.ref isn't defined, I used:
<CFHEADER statuscode="301" statustext="Moved Permanently">
<CFHEADER name="Location" value="#UniqueRSSURL#">
For the unique Id in the RSS URL I simply used:
replace(CreateUUID(),"-","","ALL"
For logging to the MySQL RSSHits table I used:
<cfquery name="updateBlogHitCounter" ...>
INSERT INTO RSSHits(ref,blogId,hits)
VALUES (<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#ref#">,
<cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#URL.blogId#">,1)
ON DUPLICATE KEY UPDATE hits = hits + 1;
</cfquery>