Home > Backend Development > PHP Tutorial > 微信中浏览器缓存了不该缓存的网页?

微信中浏览器缓存了不该缓存的网页?

WBOY
Release: 2016-06-06 20:43:30
Original
1238 people have browsed it

服务端 用的 python的flask框架
返回静态文件代码如下
flask.send_file('../static/js/main.js',cache_timeout=0)

request headers如下:

<code>GET /static/js/main.js?__inline=true HTTP/1.1
Host: anglestreet.duapp.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: */*
If-None-Match: "flask-1409227359.0-21401-527044139"
If-Modified-Since: Thu, 28 Aug 2014 12:02:39 GMT
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/36.0.1985.125 Chrome/36.0.1985.125 Safari/537.36
DNT: 1
Referer: http://anglestreet.duapp.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh,zh-CN;q=0.8
Cookie: BAEID=81F2D83EAD7D00091521BA62EDC1894B:FG=1; 
</code>
Copy after login
Copy after login

response headers如下:

<code>HTTP/1.1 200 OK
Content-Type: application/javascript
Last-Modified: Thu, 28 Aug 2014 12:02:39 GMT
Cache-Control: public, max-age=0
Expires: Fri, 29 Aug 2014 15:21:59 GMT
ETag: "flask-1409227359.0-21401-527044139"
Set-Cookie: session=eyJyb2xlIjoiYWRtaW4iLCJ1c2VybmFtZSI6ImFkbWluIn0.BuIsFw.LKeoAWvqoRfNYlU-Sk1kaz-icc4; HttpOnly; Path=/
Date: Fri, 29 Aug 2014 15:21:59 GMT
Server: BWS/1.0
Content-Length: 21401
</code>
Copy after login
Copy after login

在chrome浏览器下无问题. 在微信链接中打开则经常出现版本过期的情况, 必须手动刷新

回复内容:

服务端 用的 python的flask框架
返回静态文件代码如下
flask.send_file('../static/js/main.js',cache_timeout=0)

request headers如下:

<code>GET /static/js/main.js?__inline=true HTTP/1.1
Host: anglestreet.duapp.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: */*
If-None-Match: "flask-1409227359.0-21401-527044139"
If-Modified-Since: Thu, 28 Aug 2014 12:02:39 GMT
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/36.0.1985.125 Chrome/36.0.1985.125 Safari/537.36
DNT: 1
Referer: http://anglestreet.duapp.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh,zh-CN;q=0.8
Cookie: BAEID=81F2D83EAD7D00091521BA62EDC1894B:FG=1; 
</code>
Copy after login
Copy after login

response headers如下:

<code>HTTP/1.1 200 OK
Content-Type: application/javascript
Last-Modified: Thu, 28 Aug 2014 12:02:39 GMT
Cache-Control: public, max-age=0
Expires: Fri, 29 Aug 2014 15:21:59 GMT
ETag: "flask-1409227359.0-21401-527044139"
Set-Cookie: session=eyJyb2xlIjoiYWRtaW4iLCJ1c2VybmFtZSI6ImFkbWluIn0.BuIsFw.LKeoAWvqoRfNYlU-Sk1kaz-icc4; HttpOnly; Path=/
Date: Fri, 29 Aug 2014 15:21:59 GMT
Server: BWS/1.0
Content-Length: 21401
</code>
Copy after login
Copy after login

在chrome浏览器下无问题. 在微信链接中打开则经常出现版本过期的情况, 必须手动刷新

问题在于Cache-Control: public, max-age=0,设为Cache-Control: private就不会缓存页面

我也遇到了同样的问题,场景如下:
在a页面只能显示点赞的数量,点击点赞图标可以进入b页面,在b页面可以点赞或者取消点赞。

现在在a页面点赞数为0,我进入b页面点赞,点赞成功以后按安卓手机的返回键回到a页面,但是a页面的点赞数并没有加1。。。 试用了很多方法也不行,楼主的问题解决了吗

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template