MrRP
MrRP

Reputation: 822

nginx serves wrong the js files on change

I have a VM (built with puPHPet and vagrant). When I change a .js file the webserver serves it wrong.

This is the end of my js file:

    $(document).ready(function () {
        // $('.chat-menu-toggle').sidr({
        //     name: 'sidr',
        //     side: 'right',
        //     onOpen: function () {
        //         PslConversation.sidebarOpen = true;
        //     },
        //     onClose: function () {
        //         PslConversation.sidebarOpen = false;
        //     }
        // });
        PslConversation.init();
        window.PslConversation = PslConversation;
    });
});

When add a 3 chars to anywhere in the file, in the browser will get this on the END of the file:

��

I checked it in hex.

EF BF BD EF BF BD

If I delete anywhere in the file it will deleted from the end of the file in the browser. I tried it different browsers the result all time same.

I'm using nginx with php-fpm. If I restart the nginx nothing changes but when I change php files there is no problem, only in js and css.

I have no any cache as far as I know.

My nginx config:

server {
    listen  192.168.56.102:80;

    keepalive_timeout   70;

    listen   80;

    set $host_path "/var/www/html";

    server_name frontend.psl;
    root   $host_path/frontend/web;
    set $yii_bootstrap "index.php";

    charset utf-8;

    location / {
        index  index.html $yii_bootstrap;
        try_files $uri $uri/ /$yii_bootstrap?$args;
    add_header Access-Control-Allow-Origin *;
    }

    location ~ \.php {
        fastcgi_split_path_info  ^(.+\.php)(.*)$;

        #let yii catch the calls to unexising PHP files
        set $fsn /$yii_bootstrap;
        if (-f $document_root$fastcgi_script_name){
            set $fsn $fastcgi_script_name;
        }

        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;
    fastcgi_read_timeout 150;
        #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
    }

    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }
}

Please help to find the problem.

Upvotes: 0

Views: 1106

Answers (1)

Vitalii Koziy
Vitalii Koziy

Reputation: 11

i had same issue...

Adding this line sendfile off; in the end of nginx config file should fix it

like

    server {
        ... ... ...
        ... ... ...
        location / {
                ... ... ...
                ... ... ...
        }

        location ~ \.php$ {
          ... ... ...
          ... ... ...
        }

        sendfile off;

    }

Upvotes: 1

Related Questions