How to include a rendered php file that has been cached to HTML -
i’m creating offline web-app , working on caching method… since use jquery, being updates time, , want use cookies these:
<link rel="apple-touch-icon" href="themes/images/apple-touch-icon.png"/> <link rel="apple-touch-startup-image" href="themes/images/tstartup.png" /> <meta name="mobile-web-app-capable" content="yes" /> <meta name="mobile-web-app-status-bar-style" content="black" /> <meta name="apple-mobile-web-app-capable" content="yes" />
so send iphone… need server side php me… problem php file if it’s cached it’s not calculated… question, there way let server pre calculate site store it?
ps sorry english
you can still call php code , variables in cached files. there way how "bypass" this. don't know how cache, using php it's this:
<?php /*start caching*/ ob_start(); php or html code here /*this store "already executed code" in cache , clears buffer*/ $storecodeincache .= ob_get_contents(); ob_end_clean(); /*now @ point there piece of code want execute later, use same variable, store store php code want execute later this:*/ $storecodeincache .= 'somephpcode'; /*we start regular caching again*/ ob_start(); php or html code here /*we finished, want store rest*/ $storecodeincache .= ob_get_contents(); ob_end_clean(); /*not neccessary, when call script see has been cached*/ echo $storecodeincache ; /*write cached content file*/ $handle = fopen('safe://pathwhereyousavethecachedcontent', 'w'); fwrite($handle, $storecodeincache ); fclose($handle); ?>
the important part $storecodeincache .= ob_get_contents();
@ beggining when stopped caching - stores non-executed php code cached file - note @ point "not caching" store code cached file anywa! because did
$storecodeincache .= ob_get_contents(); ob_end_clean();
which ended caching. , doing
ob_start();
afterwards (which starts caching again). between, php cache off. can turn off php caching @ point this, store non-executed php code same variable used caching "already executed code" , move on (turn on cache again , continue).
Comments
Post a Comment