最近开发的时候,调整js时会一直使用缓存文件,无法显示改动!
nginx配置静态文件add_header Cache-Control no-cache;也不起作用,很苦恼!

nginx配置代码:
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_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;

##
# Virtual Host Configs
##

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

具体配置的server代码:
server {
listen 80 ;
server_name tp.co admin.tp.co;
root /code/think/public;

index index.php;
location ~.*\.(js|css|png|jpg)$
{
root /code/think;
add_header Cache-Control no-cache;
}
location / {
if (!-d $request_filename) {
rewrite ^/(.*)/(.*)/*$ /index.php?m=$1&a=$2 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php { #去掉$
fastcgi_pass unix:/run/php/php7.1-fpm.sock;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$; #添加
fastcgi_param PATH_INFO $fastcgi_path_info; #添加
}

}

网上找了一下资料终于解决了!使用virtualBox虚拟机,安装的nginx,不管怎么修改js,css文件,怎么强制刷新设置不缓存,都不管用,原因在于sendfile on;;这个配置在nginx.conf,将sendfile on;改为sendfile off;;再ctrl+F5,OK!完美解决!!

virtualBox 虚拟机下nginx设置不缓存静态文件不起作用解决办法的更多相关文章

  1. Springboot静态文件不更新的解决办法,以及Springboot实现热部署

    Springboot静态文件不更新的解决办法,以及Springboot实现热部署 原文链接:https://www.cnblogs.com/blog5277/p/9271882.html 原文作者:博 ...

  2. js操作serviceWorker缓存静态文件

    js操作serviceWorker缓存静态文件 serviceWorker的作用就是用来做离线应用的,在手机端程序中用的较多 先看下效果 index.html <!DOCTYPE html> ...

  3. VirtualBox虚拟机下Windows登录密码破解方法(阿里云推荐码:1WFZ0V,立享9折!)

    VirtualBox虚拟机下Windows登录密码破解方法 近两年虚拟机的发展给开发人员带来了极大便利,安装一个新环境,只需从别人那里copy一份虚拟机文件即可,分分钟搞定.我之前一直在Ubuntu下 ...

  4. 【摘自张宴的"实战:Nginx"】使用nginx的proxy_cache模块替代squid,缓存静态文件

    #user nobody;worker_processes 1; error_log logs/static_source.error.log;#error_log logs/error.log no ...

  5. virtualbox虚拟机下的cdlinux找不到无线网卡的解决方法

    virtualbox虚拟机下的cdlinux找不到无线网卡的解决方法 自己解决了,记录一下. cdlinux 带reaver1.4的版本 http://pan.baidu.com/share/link ...

  6. Virtualbox报错------> VirtualBox虚拟机下鼠标不正常的解决方法

    在Virtualbox虚拟机下,突然发现鼠标使用不正常.出现2个鼠标,一个是Ubuntu主机下面的鼠标,一个是Window7下的鼠标,但是Win7下的鼠标不可以看得到,但是点击鼠标左右键可以看到有反应 ...

  7. nginx+tomcat+二级域名静态文件分离支持mp4视频播放配置实例

    nginx+tomcat+二级域名静态文件分离支持mp4视频播放配置实例 二级域名配置 在/etc/nginx/conf.d/目录下配置二级域名同名的conf文件,路径改成对应的即可 statics. ...

  8. VirtualBox虚拟机怎么导入已经存在的vdi文件

    VirtualBox虚拟机怎么导入已经存在的vdi文件 第一章 1.原因 早上一不小心将virtualBox 卸载了,(不知道怎么了, 里面得虚拟机全部都没有了,但是vdi文件还在) 2.解决办法 直 ...

  9. NGINX不允许向静态文件提交POST方式的请求,否则报405错误(apache中没有出现)

    telnet *.*.*.* 80POST /map/navigation/2011winter/jsn/jsn_20120723_pack/pvf.jsnHTTP/1.1Host:*.*.*.* ( ...

随机推荐

  1. Android:如何获取屏幕的宽高

    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); DisplayMet ...

  2. 关于方法中的self参数和全局变

    先摆样例程序,自己想想执行结果是怎样的:如果注释掉global va后,执行的结果又会如何?同时注释掉global va和va = [value]+va两行呢? #a.py va = ['va1',' ...

  3. prototype和_proto_

    __proto__(隐式原型)与prototype(显式原型) 显式原型 explicit prototype property:用来实现基于原型的继承与属性的共享. 每一个函数在创建之后都会拥有一个 ...

  4. RESTful Web Service 架构

    特点:简单,可靠,高效,跨平台和跨语言 含义: Web Service 简单来说是指提供给不同设备通过互联网(一般使用 HTTP 协议)进行通信和交换数据的一种服务.RESTful Web Servi ...

  5. react-native “Unable to resolve module 'AccessibilityInfo'” 的解决方案

    执行 react-native run-android 安装Android APP后却是一屏大红幕报 Unable to resolve module ‘AccessibilityInfo’ 的异常 ...

  6. RMQ_ST表

    ]; ]; ]; void init(int n) { int i, j; pwr[] = ; ; i<; ++i) pwr[i] = pwr[i-] << ; ; pwr[j]&l ...

  7. 获取Linux服务器基本信息的shell脚本

    测试运行环境: SLES12SP2 #!/bin/bash #系统名称:os_type=$(uname -o | awk '{print " | "$0}') #系统位数:32/6 ...

  8. [LeetCode&Python] Problem 836. Rectangle Overlap

    A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bot ...

  9. lesson3 overfitting -fastai

    VGG:3*3Imagenet:7*7,9*9论文中证明3*3更胜一筹,但是用多少并没有定论微调:删掉模型的中间只对最后一层微调:model.pop,就删掉了最后一层 如何决定训练多少层?:·看论文上 ...

  10. (9)模板层 - templates(模板语言、语法、取值、过滤器、变量的使用)

    django的模板语言:DTL 模板语言的变量传入 这个是标签 {{ 变量名 }} {{ 变量名 }}   #模板语言的替换可以在模板中的任意位置生效 PS:通过 . 可以做深度查询 模板语言的过滤器 ...