Stuff added to  not included in cached version
This is a totally valid question in my opinion. Using the PHP input filter (or eval() in general) is almost never a good idea, but the fact that this code only runs once is not intuitive.

That said, I actually can't reproduce this.

My first thought was that the rendered HTML was being cached in the cache_filter table. But by default, the PHP Input filter is not cached in the cache_filter table. php_filter_info() from php_module:

function php_filter_info() {
  $filters['php_code'] = array(
    'title' =&gt; t('PHP evaluator'),
    'description' =&gt; t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!'),
    'process callback' =&gt; 'php_eval',
    'tips callback' =&gt; '_php_filter_tips',
    'cache' =&gt; FALSE, // &lt;- This is set to FALSE in the module
  );
  return $filters;
}


My next guess was that the anon user Page Cache was somehow ignoring the fact that those functions had been called. But I tested both drupal_add_html_head and drupal_add_js (the latter with both an external file and inline JS) and even for anonymous users, the JS was loaded and executed on all page views with and without the page cache enabled. I also tried all of these scenarios in the default body field and with a field added with the Field API.

I guess that means that my answer is one of the following:


Something is overriding php_filter_info() to set 'cache' =&gt; TRUE
You have an additional layer of caching that's causing this on your server
Something else???