[quote name="smerny" post="1466237" timestamp="1390438777"]<p>
My thoughts/questions after seeing your suggestions... Does this cache file mean that I create an xml or json file or something like that with the current data? Then instead of checking the database, each refresh (lets say I bring it to a couple seconds instead of 20) will check for the date this cache file was created. If the cache file was created more than (lets say) 2 seconds ago, it will read that. If the cache file is more than 2 seconds ago, it will ping the database and create a new cache file. This should then only ping the database every 2 seconds even with 100 people, instead of 0.2 seconds. Do I have the basic idea right?[/quote]
will this create any race conditions where multiple clients hit when the cache file is 2 seconds old or more before the first client creates the cache file?
Possibly, especially if you are updating it often and having a lot of hits. But, there are methods to lock the file until a user is done reading it. So, at worst, there might be a slight delay in updating the cache if another user is reading the content. I don't have any specifics on how to do this - but I'm sure a Google search will give you some pointers.
[/quote]will checking the creation time of this file and loading this file really be much quicker than just reading the database?[/quote]
Should be. Every time you load a web page the web server has to read all the PHP files, right? If you're not sure, test it. Create a loop to 1) run a query to get the records vs 2) reading the data from a cache file - then compare the times for each.
Having said all that, one of the responses you provided may control the best decision
I have a table with 100+ items, but only 10-15 of these items are showing at any time . . .