LINUX.ORG.RU

убрать кэширование js/css на nginx

 


0

1

Из-за всех сил пытаюсь отключить кэш js/css. Подскажите, пожалуйста. nginx 1.10.3

server {
  listen 80;

  server_name vagrant.local;
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;
  root   /var/www/test;
  index index.php;

	# serve static files directly
	location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
			access_log off;
			log_not_found off;
	}


	location / {
			# add_header Access-Control-Allow-Origin *;
			try_files $uri $uri/ /index.php?$query_string;
			# kill cache
			add_header Last-Modified $date_gmt;
			add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
			if_modified_since off;
			expires -1;
			etag off;
	}

	location ~* \.php$ {
	try_files $uri = 404;
	fastcgi_split_path_info ^(.+\.php)(/.+)$;
	fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # подключаем сокет php-fpm
	fastcgi_index index.php;
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	include fastcgi_params;
}

location ~ /\.ht {
			deny all;
	}

location ~* ^.+\.(js|css)$ {
    #old style: add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    #old style: add_header Pragma "no-cache";
    expires -1;
    sendfile off; #if you're using virtualbox (it is not about cache, but you will need it) https://www.vagrantup.com/docs/synced-folders/virtualbox.html 
}


}

пытаюсь отключить кэш

Клиент кеширует? Сервер не при чём. Надо клиенту сказать, чтоб не кешировал.

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.