网站只能ctrl+shift+f5才能看到最新内容 并且正常刷新后看到的又是之前的内容 这样可能是什么原因造成?

nginx配置如下

server {
        listen 443 ssl;  
        server_name iroboup.com www.iroboup.com;  
        root         /home/ubuntu/data/html/online/public;
        index        index.html index.htm index.php;
        ssl_certificate /etc/nginx/cert/www.iroboup.com.pem;  
        ssl_certificate_key /etc/nginx/cert/www.iroboup.com.key;

        #add_header X-Frame-Options "SAMEORIGIN";
        #add_header X-XSS-Protection "1; mode=block";
        #add_header X-Content-Type-Options "nosniff";

        client_max_body_size 200m;
        charset utf-8;

        # 这是laravel的规则
        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;
        }

        location ~ .php$ {
                try_files $uri =404;
                root /home/ubuntu/data/html/online/public;
                fastcgi_pass unix:/run/php/php-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi.conf;
        }

        error_page 404 /404.html;
        location = /40x.html {

        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {

        }

}

相同项目,相同代码,我使用http可正常访问 正常更新;使用https就看到的是第一次访问页面看到的内容

Beer
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 6

用抓包工具抓包看看内容

3个月前 评论
sanlilin (楼主) 3个月前
kis龍 (作者) 3个月前

嵌套网站吗?nginx add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; add_header Expires "Mon, 3 Jan 2000 12:00:00 GMT"; add_header Pragma "no-cache"; 加一下这个了不要缓存试试

3个月前 评论

server { listen 443 ssl; server_name iroboup.com www.iroboup.com; root /home/ubuntu/data/html/online/public; index index.html index.htm index.php; ssl_certificate /etc/nginx/cert/www.iroboup.com.pem; ssl_certificate_key /etc/nginx/cert/www.iroboup.com.key;

client_max_body_size 200m;
charset utf-8;

# SSL/TLS settings
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384';

# FastCGI configuration
location ~ \.php$ {
    try_files $uri =404;
    root /home/ubuntu/data/html/online/public;
    fastcgi_pass unix:/run/php/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi.conf;

    # Disable FastCGI cache
    fastcgi_cache off;
    fastcgi_no_cache $cookie_PHPSESSID;
    fastcgi_cache_bypass $cookie_PHPSESSID;
    add_header Cache-Control "no-cache, private";
}

# Cache control headers
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
add_header Expires "Mon, 3 Jan 2000 12:00:00 GMT";
add_header Pragma "no-cache";

# Other location blocks (if needed)
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;
}

# Error pages
error_page 404 /404.html;
location = /40x.html {}

error_page 500 502 503 504 /50x.html;
location = /50x.html {}

} 这个改一下

3个月前 评论
server {
    location / {
        # no-cache:每次都需要从服务器获取最新的资源。对于不修改时允许使用缓存的情况,可以使用public指令, public
        add_header Cache-Control "no-cache, public";

        # 控制HTTP 1.0缓存行为
        add_header Pragma "no-cache";

        # 强制资源立即过期,从而阻止浏览器使用缓存。
        expires 0;

        # 设置Last-Modified和ETag头字段,当资源未发生更改时,服务器可以返回304 Not Modified,减少无谓的数据传输。
        add_header Last-Modified $date_gmt;
        add_header ETag $etag;

        #...
    }
3个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!