while writing new code and testing it, I incorporate it into my site by testing for the remote IP address as follows; i.e., I’m the only one who will see the new code:
in /functions.php
:
// to hide certain sections/features from people other than myself
$myIP = '219.88.88.88'; // the value as currently indicated by Airport Utility
if( FALSE ) // set to TRUE to initiate Remote Addr test
define( 'ITS_ME', $myIP == $_SERVER['REMOTE_ADDR'] );
else
define( 'ITS_ME', FALSE );
in a template; eg, front-page.php
:
if( ITS_ME ) // IN DEVELOPMENT
echo gregory_get_featured_announcements();
in addition, five domains point to my server because I’m known by 5 different names in various languages. I use $_SERVER['HTTP_HOST']
in a filter function hooked to home_url()
and site_url()
that sets the domain of internal links to the host that the visitor specified.
I’d like to know; is it likely that these will put a heavy load on the server? would a cache plugin like W3 Total Cache
help?
Additional information
my apologies. the question is difficult to understand. s_ha_dum is right. I’m testing on the live server. What I’m doing would never be done in a professional setting. I’m developing my own personal blog.
ITS_ME
is a switch which evaluates to TRUE if the visitor loading the site has my IP address; i.e., the visitor is me. If the switch is on, the code within if( ITS_ME )
conditionals gets executed. This code could be in any of my WP templates. The switch is also used within functions.php
to selectively require()
in-development WP files.
wrt the domains, if a visitor visits me at domain1.com, all of the internal links will be based on domain1.com. if they visit domain2.com, all of the internal links will be based on domain2.com but otherwise, they’re seeing exactly the same content. please see https://wordpress.stackexchange.com/a/73621/15311
Gregory
Debug & Caching
…simply doesn’t work. If you’d load a page (on a cached request) and doing all those funky things like checking if you’re logged in, if you’re using an administrator-role account, etc. than all this would be bypassed by the caching plugin. The cache gets applied to the resulting HTML page, not the PHP code generating it.
NO, simply said. Extended explanation: It would make it much more worse. You’d cache all data (if the cache gets generated based on your request) and everyone would get the debug dump served. So do yourself a favor and
How to debug on a live site.
In one of my debug plugins, that I use on live servers, I got the following check on top to abort if none of the criteria is met.
So debug output will only be visible if you have the query arg
"?debug=true"
or"/debug/true"
(depending on permalink settings) appended.You can also write into a log file (but that shouldn’t be done on heavy traffic sites). Here are the lines for a
wp-config.php
file, that will suppress errors, but write them to your log file.The short answer is no, this is not a heavy load on the server. Generally speaking a simple boolean check is considered a “free” operation an will not add any significant overhead to your site.
This is actually one of the few things W3 Total Cache will not help with. You would need a code cache accelerator such as XCache or Zend Optimizer which would pre-compile and store your code to make any difference (not to say that W3 won’t be of benefit all-around). Depending on your hosting solution, you may already have one in place.
I doubt the
ITS_ME
will cause too much trouble with the server. Look like a fairly minor load to me. I’ve done far, far worse to a server. That is a pretty short answer, but I think that is it.Caching should help with the site generally but I wouldn’t think there is anything specific to this that stands out in that cache or not your operation has so low overhead I doubt you’d notice.
I’d define
ITS_ME
earlier though, say inwp-config.php
.