Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 http://wordpress.stackexchange.com/a/73621/15311

Gregory

share|improve this question

put on hold as off-topic by Pieter Goosen, Johannes Pille, ialocin, G. M., kaiser 23 hours ago

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Pieter Goosen, Johannes Pille, ialocin, G. M., kaiser
If this question can be reworded to fit the rules in the help center, please edit the question.

    
At least to me, it's a complete riddle what you're trying to do... –  kaiser Nov 27 '12 at 14:18
    
He's testing on the same server he's using for the live site and wants to hide the new/experimental code from regular users. He also appears to be sending himself private messages. He is wondering if adding these IP-based switches will cause undo load on the server. At least that is what it sounds like to me. It is not a WordPress question in any sense. –  s_ha_dum Nov 27 '12 at 14:20
    
@s_ha_dum "sending himself private messages"; I guess you could say that. for example, if I want to see the contents of a variable half-way down the front-page.php template, I'd check the ITS_ME switch and vardump() the variable if I was the visitor. –  Gregory Nov 27 '12 at 14:53

3 Answers 3

up vote 1 down vote accepted

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.

(...) would a cache plugin like W3 Total Cache help?

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

ALWAYS deactivate caching if you're debugging on a live server.

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.

// Nothing to see here
if (
    ! is_admin()
    AND isset( $_GET['debug'] )
    AND 'true' === $_GET['debug']
    AND current_user_can( 'manage_options' )
    AND ( defined( 'DOING_AJAX' ) AND DOING_AJAX )
    AND ( defined( 'DOING_CRON' ) AND DOING_CRON )
)
    return;

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.

# DEBUG
define( 'WP_DEBUG',               true );
// file: ~/WP_CONTENT_DIR/debug.log
define( 'WP_DEBUG_LOG',           true );
define( 'WP_DEBUG_DISPLAY',       true );
share|improve this answer

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?

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.

share|improve this answer

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 in wp-config.php.

share|improve this answer
    
thank you. I'll look into the wp-config.php option. one of the plugins I have codes a change to the wp-config.php file. I'll look at adapting it. –  Gregory Nov 27 '12 at 15:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.