1. Home
  2. CGI & Passenger
  3. Passenger-backed apps perform unscripted optimizations

Passenger-backed apps perform unscripted optimizations

Overview

Applications launched through Passenger, which includes Node, Python, Ruby, and Meteor, may receive optimizations to JavaScript, CSS, and image assets which are not explicitly defined within application logic.

Take for example a small external JavaScript asset that may become inlined after the first request:

<head>
<script src="//test.js""></script>
<!-- rest of head -->

becomes:

<head>
<script>//<![CDATA[
console.log("Hello 212a.");
//]]>
</script>
 <!-- rest of head -->

Cause

This is caused by an interaction between Pagespeed and Passenger. Pagespeed attempts to optimize inefficient layouts by performing a litany of optimizations, including inlining external requests that reside on the same domain if the embedded cost is less than the cost of making a subsequent HTTP request to fetch the asset.

Solution

Disable Pagespeed (see KB: Disabling PageSpeed) by locating the rule within the document root for the site. Note that Passenger-backed apps do not recursively inherit .htaccess rules as would be the case if the application were not managed by Passenger.

Updated on March 7, 2021

Related Articles