Copy link to clipboard
Copied
I'm most of the way finished with my website conversion from PHP to CF. I have a working blog, a photo gallery, and other sundry pages. It's been a really fun project, and I'm looking forward to picking up some space from Hostek and uploading my franken... errr, my new website.
The one thing I've noticed though is that when run locally, pages take AGES to load. And not just the pages with queries. Even the static pages are slow. At first I wondered if my SQL was to blame, but when I <cfdump> the query that builds my photo gallery index page, I get an execution time of zero (granted, I only have a 6 albums that show up, and 3 of them are empty).
My development machine is a Core2 Duo, 3GHz, with 8GB of ram, running Ubuntu 12.10. I have CF10 installed with MySQL 5.x and Apache2.
It just seems like locally things should be speedy, so I'm starting to suspect the dev edition of CF. Has anyone else had a similar experience?
Copy link to clipboard
Copied
Some elements of the dev edition are throttled, but not the sort of things that will impact day-to-day low-bandwidth usage.
However people write non-performant code all the time. Before wondering if CF is at fault, take a closer look at your own code.
Put some metrics in about the place and check which bits of code are running slow.
Then either work out why, or raise a question here, post the code, and we'll help get to the bottom of it.
--
Adam
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Figured it out!!!
I have a main content section on my website, then a sidebar on the right with sundry items, like a random quote, a featured pic, a list of previous blog posts, AND two RSS feeds that bring news for my two favorite things (cycling and Formula 1) into the sidebar.
In the PHP version, I had a script that I downloaded that was very complicated, but in the conversion I'm using <cffeed>.
Well, in playing around, I accidentally made a typo in the sidebar code, and the page rendered instantly. I started commenting out sections of the sidebar, and the culprit was the feed section (which makes sense, since the other items in the sidebar are cached queries).
Now that I know the culprit, maybe I can post the code and some of you can tell me what I've done wrong, or could do better.
<h4>Cycling</h4>
<ul>
<cfset rssUrl = "http://velonews.competitor.com/feed">
<cffeed action="read" source="#rssUrl#" query="cycling" properties="info">
<cfoutput query="cycling" maxrows="6"><li class="rssdesc"><a href="#rsslink#">#title#</a></li></cfoutput>
</ul>
<h4>Formula 1</h4>
<ul>
<cfset rssUrl2 = "http://www.formula1.com/rss/news/latest.rss">
<cffeed action="read" source="#rssUrl2#" query="formula1" properties="info">
<cfoutput query="formula1" maxrows="6"><li class="rssdesc"><a href="#rsslink#">#title#</a></li></cfoutput>
</ul>
Perhaps there's a way to cache these results so they only update once per day and not every single time the page is loaded. If not, I'll just leave them out altogether.
Copy link to clipboard
Copied
Ok, I've found some feed caching examples, but they all end up with a cfdump-like output. Ray Camden has one, and I found another by Andy Jarrett. They both give dump-style outpouts, and I'm having problems parsing either of them into something I can use. It's a bit frustrating!
Any's is in cfscript, which is part of what makes his tough, since I have little cfscript experience.
Copy link to clipboard
Copied
It doesn't have to be very complex: just have a task to grab the feed every 24h and stick it in the application scope. On the actual site, use what's in the application scope instead of hitting the feed URL.
--
Adam
Copy link to clipboard
Copied
My solution:
<cfset feedurl = "http://velonews.competitor.com/feed">
<cfset cacheTime = #createtimespan(1,0,0,0)#>
<cfif not structKeyExists(application,"rsscache") or dateDiff("n", application.rsscache.created, now()) gt cacheTime>
<cffeed source="#feedurl#" query="entries">
<cfset application.rsscache = structNew()>
<cfset application.rsscache.data = entries>
<cfset application.rsscache.created = now()>
</cfif>
<ul>
<cfloop query="#application.rsscache.data#" startrow="1" endrow="6">
<cfoutput><li><a href="#rsslink#">#title#</a></li></cfoutput>
</cfloop>
</ul>