jggretton Posted January 21, 2007 Share Posted January 21, 2007 Hello all, it's my first php freaks post, so hopefully you can help me out. I'm not a complete php novice, probably about average ~1 year working on and off with php.I've made a few sites in this time with some simple home-made php cms. As most of these sites are very rarely updated, it seems wasteful to query the database and run lengthly scripts for each and every page request. So I was thinking about making html caches (where appropriate) of my php pages. My scripts are currently in the form:[code=php:0]<? foreach($image as $i){ ?> <img src="<? print $i['src'];?>" alt="<? print $i['title']; ?>" ............................ /><? } ?>[/code]So it's not enough to just replace "print ..." with "$output = ...", and then fwrite $output to a file.Is there a way to instead send the output of the script to a file rather than straight to the browser. This could save me an awful lot of rewriting.Thank you very much for any help you can give me,JamesPS. I'm planning to change my htaccess rewriting to access the cached html version instead of the php thus ensuring urls don't change! Link to comment https://forums.phpfreaks.com/topic/35104-cache-html-pages-from-php-code/ Share on other sites More sharing options...
jggretton Posted January 23, 2007 Author Share Posted January 23, 2007 Sorry to bump this up, but does anyone have any clue about this. If anyone knows that it's not possible that would be extreamily useful to know too!!!Thanks a lot,James Link to comment https://forums.phpfreaks.com/topic/35104-cache-html-pages-from-php-code/#findComment-167324 Share on other sites More sharing options...
jggretton Posted January 25, 2007 Author Share Posted January 25, 2007 I could make a seperate script that opens the file from the url using fopen:[code=php:0] $handle = fopen("http://www.mydomain.com/pagetocache.php", "r");[/code]And then save this as "/home/.../pagetocache.html" using fwrite() on a new file handle.But it seems a shame to leave the server to get this info, so I was hoping someone might have a more elegant solution!Thanks,James Link to comment https://forums.phpfreaks.com/topic/35104-cache-html-pages-from-php-code/#findComment-168947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.