Web
News |
Canada's first Masters in IT security graduate
The University of Ontario Institute of Technology releases pupils from a program developed two years ago to enhance existing skills in malware and data protection. The inaugural alumni talk about their future plans...
bioLytical Partners With Virgin Mobile Canada
bioLytical Laboratories is proud to announce that Virgin Mobile Canada will be sponsoring the Test Your Commitment campaign this August. Test Your Commitment is a tri-city mobile campaign that will offer thousands of free HIV tests to Canadians in an effort to raise awareness and encourage HIV testing...
Ingram Micro Canada and Lenovo Canada partner
Lenovo has announced (July 14th, 2007) new accelerator pricing on selected T Series and L3K notebooks. This reduced pricing runs from July 15th through until September 30th. Discounts in this promotion range from $100 to an amazing $450 savings. Call your Ingram Rep today!
|
|
|
07.16.07
Saving Bandwidth On Your RSS Feed
By Pete Freitag
One of the things you will notice after you have published an rss feed is that it will consume a lot of the bandwidth.
For example on Spendfish.com 18% of the requests are for RSS feeds. This is no wonder since feed readers may download your feed several times a day even if nothing has changed.
I've put together a list of ways you can save bandwidth and reduce the number of requests to your RSS feed (which also saves server processing).
1 - Use the ttl Tag
The ttl tag goes directly inside the channel tag in your RSS feed. It stands for time to live, and should hold the number of minutes a RSS reader should wait before requesting your feed again. Most blog software defaults this setting to 60, which means that your feed will be downloaded every hour by clients that obey this setting. We can increase this to 3 hours by adding the following:
Read more about ttl here
2 - Add a skipDays tag
The skipDays tag also goes inside the channel tag and should contain several child day tags. As you might guess this tells RSS readers to skip downloading your feed on the specified days. For example if you don't publish content on the weekends:
3 - Add a skipHours tag
Same idea as the skipDays tag, but allows you to specify which hours during the day your feed should not be downloaded. The hours are specified in 0-23 using GMT. For example since I'm in NY, and I typically don't post things to my blog very early in the morning I could add:
More info about skipHours and skipDays here.
4 - Support If-Modified-Since header
Many RSS readers and clients send an If-Modified-Since header in their request to your RSS feed. This is one of the ways clients make what's called a conditional HTTP GET, you can return a 304 Not Modified HTTP response code (and omit the request body) if the RSS feed has not changed since the date specified in the If-Modified-Since header. If the content has changed you simply return the normal 200 status code.
The header sent by the client might look something like this:
If-Modified-Since: Tue, 10 Jul 2007 21:19:55 GMT
Most clients will pass in the value you specify in the Last-Modified header, so you should make sure that header is being populated. More info here. ColdFusion If-Modified-Since example here.
5 - Support ETag and If-None-Match HTTP headers
The ETag header is a HTTP response header that you can send back in your RSS feed response. It stands for entity tag and should be a unique value representing the content, you could do a MD5 hash of your RSS feed content, or simply use a date time of the last change. Clients will send this back in a If-None-Match header, if this header contains your current ETag then you can return a 304 status code. More info about If-None-Match here.
6 - Don't send the request body on HTTP HEAD requests
Here's what HTTP 1.1 has to say about the HEAD method:
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.
The HEAD method should only return HTTP headers, and no request body (so you don't need to return your entire RSS for these types of requests). You will find that several aggregators and readers will make HEAD requests for your feed (including MXNA), it's a simple way to save some bandwidth.
Read the rest of the article.
Comments
*Originally published at Pete Freitag's Homepage.
About the Author:
Pete Freitag (http://www.petefreitag.com/) is a software engineer, and
web developer located in central new york. Pete specializes in the
HTTP protocol, web services, xml, java, and coldfusion. In 2003 Pete
published the ColdFusion MX Developers Cookbook with SAMs Publishing.
Pete owns a Firm called Foundeo (http://foundeo.com/) that specializes
in Web Consulting, and Products for Web Developers. |
|