Hi,
I am working on a sql-query intensive homepage and have decided to grab the php output to a html and store it for 5 mins and whenever the user writes mysite.com i just display the readily available html file.
Can you help me work on this concept with ideas and suggestions?
Faster loading using static html
Moderator: General Moderators
Re: Faster loading using static html
So basically a cache?
What are you having trouble with?
Btw, a better option may be to make your queries more efficient.
What are you having trouble with?
Btw, a better option may be to make your queries more efficient.
Re: Faster loading using static html
basically how to read the php script output into html file maybe every 5 mins for instance
Re: Faster loading using static html
Well, you could put
In the cached file.
Then, when you include that file, check if it's value is null. If it is, write a new version. Instead of echoing stuff out, assign it to a variable, and write the variable to the file, then echo the variable.
There are plenty of tutorials on google for writing cache systems with php.
Code: Select all
if(time() > $time_inserted_when_written_for_cache_timeout) return null;Then, when you include that file, check if it's value is null. If it is, write a new version. Instead of echoing stuff out, assign it to a variable, and write the variable to the file, then echo the variable.
There are plenty of tutorials on google for writing cache systems with php.