Y
Y
Yuriy2020-09-28 12:00:40
Nginx
Yuriy, 2020-09-28 12:00:40

Nginx how to add file caching exception?

You need to add a caching exception folder in it, /upload/export/products/

Here is a piece of code in the nginx config

location ~* ^.+\.(css|js)$ {
      rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
      expires 31536000s;
      access_log off;
      log_not_found off;
      add_header Pragma public;
      add_header Cache-Control "max-age=31536000, public";
    }

    location ~* \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
      expires 31536000s;
      access_log off;
      log_not_found off;
      add_header Pragma public;
      add_header Cache-Control "max-age=31536000, public";
    }

    location ~ /upload/export/products/.*(\.zip|\.json|\.xml)$ {
      proxy_cache off;

      proxy_intercept_errors off;
      proxy_read_timeout 30s;
      proxy_send_timeout 30s;
    }


inserted this piece location ~ /upload/export/products/.*(\.zip|\.json|\.xml)$ restarted nginx, but the files are still in the cache. I NEED HELP....

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