5

Not so long ago I was having trouble with javascript assets. When I made changes to them they wouldn't take effect and the file would become invalid javascript (firebug throwing errors and warnings).

I noticed that my changes weren't appearing and special characters were being added to the end of the file. A bit more digging and I noticed that the special characters were exactly the number of characters of my edits.

Original code:

$(document).ready(function(){
     alert('what');
});

Adding a line, should looks like this:

$(document).ready(function(){
     alert('what');
     alert("what's going on?!);
});

Renders like this:

$(document).ready(function(){
     alert('what');
});��������������������������

When I researched I found that modifying apache config's /etc/httpd/conf/httpd.conf and commenting out EnableSendfile off fixed the issue.

However...

Now the issue has returned, but apache config hasn't changed.

Please help. My current work around is renaming the file, viewing the new file and naming it back; this annoys me tremendously.

I'm developing on a vagrant box, CentOS 6, PHP 5.3/apache 2 - the original solution can be found here: Shared folder in VirtualBox for Apache.

Unfortunately this no longer seems to work.

Community
  • 1
  • 1
joseym
  • 1,332
  • 4
  • 20
  • 34
  • Have you checked for invisible characters like windows line breaks? tabs / spaces? – Chris Whittington Mar 22 '12 at 16:47
  • Yes, the file is clean. Only new changes are converted to these special characters. – joseym Mar 22 '12 at 16:56
  • You could use some cache busting like ``. But since I am inexperienced with apache you may want to wait for a better suggestion. – Prusse Mar 22 '12 at 17:50
  • Prusse - cache busting doesn't work, it seems to be the way the file is served up. – joseym Mar 22 '12 at 18:04
  • 1
    Possible duplicate of [Vagrant/VirtualBox/Apache2 Strange Cache Behaviour](http://stackoverflow.com/questions/9479117/vagrant-virtualbox-apache2-strange-cache-behaviour) – kenorb May 09 '16 at 15:18

1 Answers1

7

Often when EnableSendfile On causes breakage, EnableMMAP causes similar issues. Try turning that off too. You mentioned that you're using CentOS in Vagrant but not the host OS. Is it Windows perchance?

noodl
  • 17,143
  • 3
  • 57
  • 55