php - automatically pre-caching webpages -
currently, website employs caching system newly requested pages generated cached on fly future faster execution. format overall in pseudo code:
see if cached page exists. if cached page exists load cached page exit if cached page not exist generate page save output cache file exit every newly requested page takes between 250 , 500 ms of load time , every cached page takes between 100 , 200 ms of load time.
what want upon every manual website update, want pre-cache pages (i think called cache priming).
my cache system done in php , thought of making wrapper php script calls main script generates webpage appropriate parameters loaded. in code, thought:
<?php //wrapper script pre-cache 500 pages ($sect=1;$sect<500;$sect++){ $_get['param1']="sectiontocache"; $_get['sectionno']=$sect; include "index.php"; } ?> and index.php (which requires chunk of memory) outputs correct html based on input parameters.
i feel if did way, i'd either place huge burden on server , or receive out of memory errors since on each website update, @ least 100 500 pages need cached deliver optimal performance on every request made client.
if this:
<?php //wrapper script pre-cache 500 pages ($sect=1;$sect<500;$sect++){ $_get['param1']="sectiontocache"; $_get['sectionno']=$sect; include "index.php"; declude "index.php"; } ?> then i'd happy.
yes i'm aware declude isn't valid keyword, point i'm trying make want release memory index script after has been processed don't run errors.
i'm wondering if should still use first php script have shown , pray server wont crash, or if theres better official way pre-cache pages in situation.
i suggest solution:
create page include javascript timer (let's need 1 sec generate 1 page) :
each 1 sec , refresh page javascript including next $sect parameter.
get parameter value in php code, generate page.
in javascript, add condition stop process if $sect if > 500
i hope clear in explanations.
Comments
Post a Comment