0

Running into this problem.. nginx seems to persist files that are no longer on disk, its not a browser cache issue as I can test it with curl..

eg.. curl https://staging.xxxx.co/ <!DOCTYPE html><ht ... src="/app/main.92974ab5ce4e059cd6a0.js .. this file no longer exists on disk..

rebooting solves the problem - eg. curl https://staging.xxxx.co/ <!DOCTYPE html><ht ... src="/app/main.5920b750cb8af60be300.js ..

my config file

# HTTPS server
server {
    ssl on;
    ssl_certificate /etc/letsencrypt/live/db.xxxx.co/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/db.xxxx.co/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    #ssl_dhparam /etc/ssl/dhparams.pem;
    #ssl_session_timeout 5m;
    #ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;
    # Remove the # from the following line once you are sure everything works
    # add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    add_header X-Clacks-Overhead "GNU Terry Pratchett";
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.4.4 8.8.8.8 valid=300s;
    resolver_timeout 5s;       

    listen 443 ssl;
    listen [::]:443 ssl;
    server_name staging.xxxx.co;

    root /var/www/staging.xxxx/current/public;
    index index.html index.htm index.php;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            # try_files $uri $uri/ =404;
            try_files $uri $uri/ /index.php?$query_string;
                expires 1;

            # Do not cache index.html, SPA
            location = /app/index.html {
                    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max
-age=0';
                    proxy_no_cache 1;
                    expires 1;
                    try_files /app/index.html =404;
            }

            # Do not cache sw.js, required for offline-first updates.
            location /sw.js {
                    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max
-age=0';
                    proxy_cache_bypass $http_pragma;
                    proxy_cache_revalidate on;
                    expires 1;
                    access_log off;
            }
    } 

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #   include snippets/fastcgi-php.conf;
    #
    #   # With php7.0-cgi alone:
    #   fastcgi_pass 127.0.0.1:9000;
    #   # With php7.0-fpm:
    #   fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #}
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        expires 1;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
    location ~ /\.ht {
            deny all;
    }
}

Any suggestions? I've already checked Nginx Seems to be Sending Cached Versions of Pages

linux server is ubuntu 16.04 - up to date, nginx/1.10.3 (Ubuntu), php 7.2

  • yes, as you can see above.. – baradhili Jan 26 at 11:03
  • so basically.. in nginx.conf.. sendfile is off and no proxy is enabled.. – baradhili Jan 28 at 2:48

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.