22, August 2008

best way to cache RSS data - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: best way to cache RSS data
« previous next »
Pages: [1] Print

Author Topic: best way to cache RSS data  (Read 1321 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6300
38626 credits
Members referred : 374


It's time to use PHP5!


« on: Apr 25, 2007, 10:12:25 PM »

Hi,

juts to be sure...

after I parsed some RSS feed and want to cache this data, what is the best way to do that:

1. parse the xml into an array
2. serialize the data
3. write to a file

for reading a file:
read the file to get the string  and unserialize to get (again) the array?


Last blog : Create custom backups from your website using cURL
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8020
41077 credits
Members referred : 3



« Reply #1 on: Apr 25, 2007, 10:16:23 PM »

It depends in the size of data you want to cache. That looks ok for some data, but for more feeds you probably need a database Smiley

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6300
38626 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Apr 25, 2007, 10:25:23 PM »

It depends in the size of data you want to cache. That looks ok for some data, but for more feeds you probably need a database Smiley
sure its possible that there are 100 or more files but each file is not bigger the 30-50KB


Last blog : Create custom backups from your website using cURL
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8020
41077 credits
Members referred : 3



« Reply #3 on: Apr 25, 2007, 10:35:18 PM »

I guess that's fine.

BTW magpie has caching embedded.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6300
38626 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Apr 25, 2007, 10:40:03 PM »

I guess that's fine.

BTW magpie has caching embedded.

but magpie doesn't parse all youtube data Wink

I use simpleXML for parsing


Last blog : Create custom backups from your website using cURL
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #5 on: Apr 28, 2007, 03:00:11 AM »

does cached files overwrite itself or a new file is added everytime the old one expires thereby taking up storage space so there is a need to delete them from time to time?


Last blog : Punta Engano Beach, Cebu, Philippines
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6300
38626 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Apr 28, 2007, 09:26:21 AM »

does cached files overwrite itself or a new file is added everytime the old one expires thereby taking up storage space so there is a need to delete them from time to time?

the name of the cached file is still the same, script looks after the last modfied date, will say there is only one file for each url, yes right if you have 100.000 urls there are 100.000 cache files Smiley


Last blog : Create custom backups from your website using cURL
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8020
41077 credits
Members referred : 3



« Reply #7 on: Apr 28, 2007, 01:53:00 PM »

BTW if this is going to be user triggered, be sure to use the flock function Visit through proxy Wink

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6300
38626 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Apr 28, 2007, 02:34:49 PM »

BTW if this is going to be user triggered, be sure to use the flock function Visit through proxy Wink

I read about flock before, but these file are created by the class (md5(url))


Last blog : Create custom backups from your website using cURL
Where are my glasses?
*
Posts: 21
138 credits
Members referred : 0


« Reply #9 on: Jul 20, 2007, 01:43:58 AM »

I was looking two days for the best method to cache contents. For plain data I'd use file_get_contents() and file_put_contents(). For caching loops I can recommend SQLite. It has the best performance to read out big data in a short period of time. I posted the full story at http://phpperformance.de/ausgaben-in-cache-speichern/ Visit through proxy (last comment). Unfortunately it's in German.
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8020
41077 credits
Members referred : 3



« Reply #10 on: Jul 20, 2007, 01:46:04 AM »

You mean SQLite is faster than plain text files?

How many records you used for your test?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Where are my glasses?
*
Posts: 21
138 credits
Members referred : 0


« Reply #11 on: Jul 20, 2007, 01:54:37 AM »

The MySQL table consists of 1.000.000 records but I did only read out 20.000 of them. I had a performance boost of ~500%.
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6300
38626 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Jul 20, 2007, 09:30:28 AM »

Makes sense since sqllite is file based too.

At the moment that I started this thread the directory with cached file becomes bigger than 100.000 files.

this amount was not a problem, later I decided to create a cronjob to remove files older than a week. This job is holding the amount of files near the 100.000 files and I'm happy with that.

but anyway using sqllite for caching sound interesting.

Tim do you checked also the filsize for the database is this bigger smaller than for the file based cache?

how about the server load while reading some file/record?


Last blog : Create custom backups from your website using cURL
Where are my glasses?
*
Posts: 21
138 credits
Members referred : 0


« Reply #13 on: Jul 20, 2007, 03:55:29 PM »

Maybe it would be better if you check the creation time of the caching file before every usage. Then consider deleting it if it's older than one week, refresh the RSS newsfeed and rewrite the cache or use the data of the cache.

I haven't yet used my caching method in production use but I don't think the server load would be much higher than by using ordinary files. As I've already said, this method is high recommendable if you need to cache loops because you can't jump between records with fseek()/ftell()/fgets() as fast as you can with SQLite . I didn't find any better solution being based on files. Another solution would be to create a second MySQL server which runs at another port instead of using SQLite. Does MySQL have a better performance than SQLite?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8020
41077 credits
Members referred : 3



« Reply #14 on: Jul 20, 2007, 03:59:05 PM »

Of course mysql has better performance. SQLite is good for small databases, and besides that I don't know how it will handle many concurrent connections (while the file system and mysql will be ok with this)

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6456
Tags : rss cache Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: best way to cache RSS data
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Aug 22, 2008, 01:32:14 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.084
Total Topics: 7.439
Total Members: 3.807
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: marthawelch

38 Guests, 2 Users online :

16 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.