zkoneffko Posted October 15, 2008 Share Posted October 15, 2008 I currently have a file that I load on every page of my site with a php include statment: <?php require(DIR_WS_INCLUDES . 'inst/catalog.php'); ?>. The file loading is rather large and takes a while to download and load. Is there a way to have the file somehow temporarily saved to the local computer or cached so it does not have to completely reload every time? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 15, 2008 Share Posted October 15, 2008 What is DIR_WS_INCLUDES set to? Quote Link to comment Share on other sites More sharing options...
zkoneffko Posted October 15, 2008 Author Share Posted October 15, 2008 \admin\includes I not sure how that would affect the load time. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 15, 2008 Share Posted October 15, 2008 "\admin\includes/inst/catalog.php" would be a local file, so there is no downloading going on... Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2008 Share Posted October 15, 2008 What file size is catalog.php? Quote Link to comment Share on other sites More sharing options...
xtopolis Posted October 15, 2008 Share Posted October 15, 2008 Are you sure it's the process of being included, or rather what's in the include that's causing the slow down? explain in a nutshell what your included script does, or try running only that page to see if it's slow on its own... Quote Link to comment Share on other sites More sharing options...
zkoneffko Posted October 15, 2008 Author Share Posted October 15, 2008 It's definetly the file size. It's about 700k. I know it's the file that is slowing it down. When I remove the file and replace it with a blank file of the same name it load instantly. That's why I want to find a way to cache the file so it only loads slow the first time and then each time it is called while they are still on the site it would call the cached file and not have to redownload it. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2008 Share Posted October 15, 2008 Web servers are stateless. Each request for a web page is completely separate from all others and all resources used by any web page are destroyed when the script on that page ends. About the only thing you could directly do is use a RAM disk to hold the file so that it would load at memory speed instead of disk speed. However, based on the file name, you should have switched to using a database a long time ago so that you can just query for the relevant information used on any page instead of needing to read in the whole catalog file. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2008 Share Posted October 15, 2008 You can check if the memcache extension is available on your server - http://us.php.net/memcache Quote Link to comment Share on other sites More sharing options...
zkoneffko Posted October 15, 2008 Author Share Posted October 15, 2008 Thanks for the responses but isn't there a way to have it cache on the client side? Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 15, 2008 Share Posted October 15, 2008 What the heck ya got in a 700k include file? Quote Link to comment Share on other sites More sharing options...
zkoneffko Posted October 15, 2008 Author Share Posted October 15, 2008 About a 100 page word document converted into an expandable manual. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 15, 2008 Share Posted October 15, 2008 Is this something that is viewed online or sent to the browser, like as a download? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2008 Share Posted October 15, 2008 The APC (Alternate Php Cache) also has variable store/fetch ability - http://us2.php.net/apc Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 15, 2008 Share Posted October 15, 2008 what is the difference between include and require? Quote Link to comment Share on other sites More sharing options...
zkoneffko Posted October 15, 2008 Author Share Posted October 15, 2008 Everypage that is loaded shows the manual on the page. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 15, 2008 Share Posted October 15, 2008 what is the difference between include and require? If require fails, execution of the script stops, if include fails, it throws a warning but the script execution continues. Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 15, 2008 Share Posted October 15, 2008 wow I might wanna start using require. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted October 15, 2008 Share Posted October 15, 2008 @ Lamez The behavior of the php script if the file is not found. (Type of error, script termination, etc) Quote Link to comment Share on other sites More sharing options...
Zane Posted October 15, 2008 Share Posted October 15, 2008 have you checked out ob_start() and ob_end_flush() ob_start(); include($fileToInclude); $ret = ob_get_contents(); ob_end_clean(); Quote Link to comment Share on other sites More sharing options...
Dead6re Posted October 15, 2008 Share Posted October 15, 2008 Heres your problem and it has nothing to do with caching. Your saying your file is 700kb big? If so, optimize that!!! Obiviously files server side will be bigger as they get parsed and show only the input you want. Split the code into different files based on what they do so you don't use memory storing scripts you won't be using. Remove unneeded HTML code and start using CSS to dress up the HTML instead. The displayed filesize by the phpfreaks forum for this page is roughly 6kb. The SMF boards looks to only include less than 100-200kb of actual PHP files. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2008 Share Posted October 15, 2008 An include statement might somehow be related to this file, but the actual problem is this file is content that is sent to the browser. A Word document is not web friendly. You might have gotten this to do what you want, but as you have found out, it is not an effective way of publishing a catalog on the Internet. No matter what you do with your existing system, you will only be able to make minor improvements. If you provide information on what you actually have and what you are doing on the site, someone can provide direction on the best way of accomplishing it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.