Jump to content

[SOLVED] Require/Include_Once


2K

Recommended Posts

When used as intended with a local file path, they don't use or affect bandwidth at all. When used improperly with a URL, they use twice the bandwidth of the content because your server is both getting that content from where it is at using a http request and then outputting that content to the browser.

 

For the second case, where a URL is being used, using the once_ versions would save on part of the bandwidth being used if you were including the same content more than once on a page. If you are including the content only once anyway, using the once_ versions does not help at all and in fact the once_ versions take slightly longer because php must first check the table of included files before actually reading the content, whereas the non-once_ versions just direct read the content.

Edit to the above: If you are using a URL and you are getting that content from your own server, you are actually using three times the bandwidth of that content. Once when your server outputs it in response to the http request your php script made by requesting it through a URL. Second when it is read in by your php script with the include/require statement in it. Third when you output it to the browser.

Per your PM question -

 

Each request a browser makes for a page is completely separate from every other request it makes for that same page or a different page. Using the _once versions or non-_once versions have no effect between different requests for one page or requests for any other page on your site.

 

Include/require and the _once versions of those are not shared between requests. The file reads might be cached by the operating system for a short time, so requests for pages using the same include file close together would benefit.

 

Again, if you are reading local files using a file system path, there is no affect on your hosting bandwidth.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.