Nginx 服务器(未显示更改)- 删除缓存?
Nginx server (not showing changes) - Delete cache?
我是 运行 Nginx 上的一个 Laravel 站点 (Ubuntu)(不是虚拟框)。当我更改 css 文件或与此相关的任何文件时,我无法立即看到更改。我已尝试将 sendfile 从打开更改为关闭,如 link 中所述:
How to clear the cache of nginx?
而且我找不到删除缓存的Nginx缓存文件。许多站点建议转到 "path/to/cache" 文件夹,但我找不到它:
https://www.nginx.com/blog/nginx-caching-guide/
无论如何,我认为我没有设置任何类型的代理缓存或任何东西。伙计们,有什么想法可以找到我的缓存以便删除它吗?就此而言,我是否希望在这里做正确的事情?感谢您提前回答。
这是我的测试服务器块的样子:
server {
# secure website with username and password in htpasswd file
auth_basic "closed website";
auth_basic_user_file /tmp/.htpasswd.txt;
listen (myip) default_server;
listen [::]:83 default_server ipv6only=on;
root /var/www/test/(sitefolder);
index index.php index.html index.htm;
# Make site accessible
server_name (myiphere);
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
这是我的真实站点服务器块的样子:
server {
# secure website with username and password in htpasswd file
auth_basic "closed website";
auth_basic_user_file /tmp/.htpasswd.txt;
listen (myip) default_server;
listen [::]:81 default_server ipv6only=on;
root /var/www/(mysite)/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name (myip);
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
首先,css是客户端缓存的东西,不是服务器。您应该清除浏览器的缓存以查看 css 更改。此外,浏览器缓存是 css 和 javascript 开发中的常见问题。幸运的是,您可以利用 laravel 5.1 附带的 elixir 来防止浏览器缓存您的资产。
访问文档以获取有关 laravel 长生不老药的更多信息。
http://laravel.com/docs/5.1/elixir#versioning-and-cache-busting
其次,laravel 为我们提供了一个方便的命令来清除您服务器的缓存:
php artisan cache:clear
更新:
server {
listen 80;
server_name example.com;
root "/usr/share/nginx/app/public";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/app-error.log error;
client_max_body_size 100m;
include hhvm.conf;
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name beta.example.com;
root "/usr/share/nginx/beta/public";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/app-error.log error;
client_max_body_size 100m;
include hhvm.conf;
location ~ /\.ht {
deny all;
}
}
我是 运行 Nginx 上的一个 Laravel 站点 (Ubuntu)(不是虚拟框)。当我更改 css 文件或与此相关的任何文件时,我无法立即看到更改。我已尝试将 sendfile 从打开更改为关闭,如 link 中所述:
How to clear the cache of nginx?
而且我找不到删除缓存的Nginx缓存文件。许多站点建议转到 "path/to/cache" 文件夹,但我找不到它:
https://www.nginx.com/blog/nginx-caching-guide/
无论如何,我认为我没有设置任何类型的代理缓存或任何东西。伙计们,有什么想法可以找到我的缓存以便删除它吗?就此而言,我是否希望在这里做正确的事情?感谢您提前回答。
这是我的测试服务器块的样子:
server {
# secure website with username and password in htpasswd file
auth_basic "closed website";
auth_basic_user_file /tmp/.htpasswd.txt;
listen (myip) default_server;
listen [::]:83 default_server ipv6only=on;
root /var/www/test/(sitefolder);
index index.php index.html index.htm;
# Make site accessible
server_name (myiphere);
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
这是我的真实站点服务器块的样子:
server {
# secure website with username and password in htpasswd file
auth_basic "closed website";
auth_basic_user_file /tmp/.htpasswd.txt;
listen (myip) default_server;
listen [::]:81 default_server ipv6only=on;
root /var/www/(mysite)/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name (myip);
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
首先,css是客户端缓存的东西,不是服务器。您应该清除浏览器的缓存以查看 css 更改。此外,浏览器缓存是 css 和 javascript 开发中的常见问题。幸运的是,您可以利用 laravel 5.1 附带的 elixir 来防止浏览器缓存您的资产。
访问文档以获取有关 laravel 长生不老药的更多信息。
http://laravel.com/docs/5.1/elixir#versioning-and-cache-busting
其次,laravel 为我们提供了一个方便的命令来清除您服务器的缓存:
php artisan cache:clear
更新:
server {
listen 80;
server_name example.com;
root "/usr/share/nginx/app/public";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/app-error.log error;
client_max_body_size 100m;
include hhvm.conf;
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name beta.example.com;
root "/usr/share/nginx/beta/public";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/app-error.log error;
client_max_body_size 100m;
include hhvm.conf;
location ~ /\.ht {
deny all;
}
}