0

In addition to making debugging almost impossible, this new behavior is breaking my website where I use the heredoc javascript technique, (Javascript heredoc) which depends on using comments.

I'm not sure if I inadvertably turned this on, and this is a rare occurrence, or if this is a new Android feature. I'm concerned because I use the heredoc javascript technique on a number of different sites, and this behavior will break these sites.

Has anyone else experienced this?

Is there a workaround where the server can stop this?

Is there an alternative to the heredoc javascript technique?

Community
  • 1
  • 1
MLU
  • 181
  • 1
  • 6

2 Answers2

1

This problem was caused by chrome data-compression (https://developer.chrome.com/multidevice/data-compression.) Thank to Slaks for the heads up, or I would have missed it.

Once I turned it off - it's in Chrome Settings - Reduce data usage (after Content Settings and before About Chrome), my site began to work again.

In order to fix it for other users who like me are not even aware that they are using this, I added the following code, that I found in the two references below:

<FilesMatch "\.(css|js)$">
    <IfModule mod_headers.c>
        Header set Pragma "public"
        Header set Cache-Control "no-transform,public, must-revalidate, proxy-revalidate"
    </IfModule>
    FileETag MTime Size
</FilesMatch>

The important part is telling Google "no-transform" on the javascript via the Cache-Control directive. I did this for both .js and .css files, though I might add additional types in the future.

And, I added headers.load to mods-available to that it would have mod_headers.

http://mobiforge.com/design-development/setting-http-headers-advise-transcoding-proxies

Apache -Caching: How to Configure Response headers in Apache 2+.

After restarting Apache, everything worked fine.

In terms of the 3rd question, is there a workaround for the javascript heredoc method, I don't really have an answer, but perhaps this scenario is indicative that this method is not without problems.

Community
  • 1
  • 1
MLU
  • 181
  • 1
  • 6
0

I'm the tech lead for the Google compression proxy. Our proxy does indeed remove comments from JS files, which should be safe - although there are some tools which (perversely, in my opinion :-) rely on JS comments to work. In general there is no good way to detect this, so we rely on the Cache-Control: no-transform header. If you have suggestions for better ways to avoid this I'd appreciate it.

mdwelsh
  • 398
  • 2
  • 8