Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posts that are served through caching plugins like batcache bypass disable_nr_autorum() logic #10

Open
goldenapples opened this issue Mar 17, 2017 · 1 comment
Labels
help wanted type:enhancement New feature or request.
Milestone

Comments

@goldenapples
Copy link
Contributor

goldenapples commented Mar 17, 2017

I've noticed on a production site that posts which are retrieved through batcache seem to be getting New Relic's <script> tags embedded, in cases where it should be disabled.

An example is AMP pages. On the initial page render, the action pre_amp_render_post action is fired, which causes disable_nr_autorum() to fire, preventing the New Relic browser scripts from being injected on the page.

However, if that same page request is served through batcache, the appropriate action isn't fired, and New Relic scripts are inserted (in some cases, re-inserted) into the HTML markup retrieved from memcache.

This may not be an issue that can be easily fixed in this plugin, but I wanted to open an issue here to track progress on it. It may be possible to output a special vary_cache_on function if batcache is detected. If not, and this is something that needs to be fixed with a special nginx directive or a function in the wp-config file, it would be good to at least have it documented here. Perhaps we can show example code that users can copy into their webserver configuration in an admin notice or help page?

@jasondewitt
Copy link

I have been able to implement a work around for this by wielding the great and terrible power of nginx aginst it. Use a regex to detect the /amp/ routes being requested and inject a fastcgi_param PHP value to disable auto instrumentation

        set $param "";
        if ( $request_uri ~* /amp/ ) {
                set $param "newrelic.browser_monitoring.auto_instrument=0";
        }
        location ~ \.php$ {
                fastcgi_param PHP_VALUE $param;
                ....rest of php config.....

it's worth noting, that if you are injecting any other PHP_VALUE parameters, they will overwrite each other and you will need to put them all into a single PHP_VALUE parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted type:enhancement New feature or request.
Projects
Status: To Do
Development

No branches or pull requests

3 participants