K
K
kr_ilya2019-06-14 11:29:57
Nginx
kr_ilya, 2019-06-14 11:29:57

Where is the file cached and how to clear such a cache?

There is a site on nuxt.js (vue.js ssr), caching is enabled on it , by default 15 minutes. There is also caching from nginx

nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
# worker_processes 8;
events {
  worker_connections 768;
  # multi_accept on;
}

http {
  
  ##
  # Basic Settings
  ##

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  # server_tokens off;

  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  ##
  # SSL Settings
  ##

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  ##
  # Logging Settings
  ##

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  ##
  # Gzip Settings
  ##

  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_buffers 16 8k;
  gzip_comp_level 6;
    gzip_min_length 100;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  # gzip_vary on;
  # gzip_proxied any;
  # gzip_comp_level 6;
  # gzip_buffers 16 8k;
  # gzip_http_version 1.1;
  # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=all:32m max_size=1g;
  
  ##
  # Virtual Host Configs
  ##

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
}

sites-enabled/default

map $sent_http_content_type $expires {
    "text/html"                 epoch;
    "text/html; charset=utf-8"  epoch;
    default                     off;
}

server {
    listen          80;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/ssl/sitecrt; 
    ssl_certificate_key /etc/ssl/site.key;         # the port nginx is listening on
    server_name site.ru www.site.ru;    # setup your domain here
    root /root/site;

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    location / {
        #return 503;

        expires $expires;

        proxy_redirect                      off;
        proxy_set_header Host               $host;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_read_timeout          1m;
        proxy_connect_timeout       1m;
        proxy_pass                          http://127.0.0.1:3001; # set the adress of the Node.js instance here
    }

    location /api/ {
        #return 503;
        
        proxy_redirect                      off;
        proxy_set_header Host               $host;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_read_timeout          1m;
        proxy_connect_timeout       1m;
        proxy_pass https://127.0.0.1:3000/;
    }

    error_page 500 502 503 504 /50x.html;

    location = /50x.html { 
        root /var/www/errors;
    }
}


The problem is that after updating the files (using the nuxt build command and then replacing the .nuxt folder on the server), the server returns the previously generated and cached html page file, which loads the old .js files that return 404.
I tried the commands:
find /var/ cache/nginx -type f -delete
echo 3 > /proc/sys/vm/drop_caches
apt-get clean.
None of this had any effect. I waited 15-20 minutes, nothing changed.
Everything starts working as it should only after rebooting the server itself. What could be the problem and how to solve it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question