Find The Speed Of Every Page In Your Website

Share this on:

Time To First Byte (TTFB) is a ranking factor in Google's algorithm

How fast are the pages on you website?

The script below will tell you.

You need a computer running Linux, and your site will need a sitemap.xml file. ( If you use MODX try the GoogleSiteMap plugin to generate your sitemap)

How it works: curl grabs your sitemap.xml file we then extract all the links using sed and awk then use curl again to call each individual page.

You get a nice output with the individual URL followed by the time to first byte for that page.

In MODX when you save any resource the entire cache is deleted, so every page will be slower the next time it is loaded. So this script has the added advantage that it calls every page and thus regenerates the cache for every page.

if [ [ $@ ] ]; then
echo -e "\nusage: ./regenCacheFromSitemap url-of-sitemap\n"
exit 1

echo -e "\n"

curl -s $1 2>&1 | sed -n '/<loc>http/p' | sed 's/<[^>]*//g; s/>//g; s///g' | awk '{

print "\n\n" $1
p="curl -s -o /dev/null -w '%{time_starttransfer}' " $1

echo -e "\n"

Note: there should be no gap between the square brackets [ [ & ] ]. If I put them in like that MODX thinks its a snippet!

Curl has its errors directed to stderr to stdout 2>&1 but it is used in silent mode so we won't get any messages interrupting the lines of sitemap.xml

Share this on:
Mike Nuttall

Author: Mike Nuttall

Mike has been web designing, programming and building web applications in Leeds for many years. He founded Onsitenow in 2009 and has been helping clients turn business ideas into on-line reality ever since. Mike can be followed on Twitter and has a profile on Google+.