Option #2 sounds interesting, can you please elaborate?
Main Topics
Browse All TopicsHello everyone,
Looking for a method to use dynamic content from either a database or XML source that is retrieved using PHP, but I want the content to cache if it has not changed at all. Basically, I don't the PHP to keep on making requests to the database if the content has been the same for the last hour.
What methods or solutions do you recommend for this? I've heard a reverse proxy cache works well, but I heard some sort of publishing mechanism works better.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Imagine this ...
User makes request to say report.php
Server gets report.php and simply echos from a HTML file.
Using cron or some other scheduling system, you create the HTML file just like you are currently doing (i.e . doing to the DB, getting the data, etc.)
The simplest way would be to wrap the current script in a output buffer and then write the buffer to the cached HTML file.
Sorry to follow up again, what do you mean when you say:
"Server gets report.php and simply echos from a HTML file."
Somebody requests the php file, and it the information comes from the HTML, so the HTML is created from cron (the scheduling system), interesting. Now that I type it, I start to understand, haha. Is cron hard to use, how do I populate the HTML file with cron? (I was going to ask if it is better to use XML but I figure PHP will echo HTML much faster)... thanks!
What I do is I have a cronjob run every hour on the hour and run a link that will update a text file with whatever results.
Example
The write to a file is the one you would cron every hour.
The read from file is the page you need tor read.
That's just an example you can save the data however you want and export it however you want.
well I just followed what I was reading, and I gave my input we are however different users not the same guy.
Anyway the cron job you can have your host set up for you, or you can set it up through cron through cpanel. There's many methods on implementing this, but it mostly depends on the host, I would talk to your host if you are not under cpanel or something along those lines.
To make the actual changing data initiate the cache file creation requires either an alteration to the application making the change to the data or some sort of monitoring system to see when the data changed.
This mechanism has to have a semaphore lock to stop the cache building code from running simultaneously (fast changes and a slow cache build process for example could end up with multiple and simultaneous cache build processes - bad news).
For a semaphore, I create a folder. They are atomic, the act of creating a folder will either succeed (the folder didn't exist and it does now) or not (the folder already exists).
If you can create the folder, you've got the lock/semaphore.
If you can't then someone else has.
Once you've finished with the building process, you remove the folder.
This works across all the different OS's I've worked on.
Business Accounts
Answer for Membership
by: RQuadlingPosted on 2008-02-07 at 12:15:26ID: 20844550
With any sort of cache, you need to have a way of knowing when to get new data.
There are 2 ways that I would think are relevant.
1 - Trigger the creation/update of the cache when data changes. This is the way to go if your data is changed VERY infrequently.
2 - Regularly expire the cache and refresh it automatically. If you have rapidly changing data then this is the way to go.
If you can tell me which of these 2 scenarios fit your data, I can expand on them further.