Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete query strings #963

Merged
merged 2 commits into from
Oct 23, 2019
Merged

Delete query strings #963

merged 2 commits into from
Oct 23, 2019

Conversation

1v9
Copy link
Member

@1v9 1v9 commented Jul 10, 2019

A little bit of work 😎, if useless just close it.

@1v9 1v9 added this to the v7.3.0 milestone Jul 10, 2019
@1v9
Copy link
Member Author

1v9 commented Jul 10, 2019

I don't see docs of Assets...

@jiangtj
Copy link
Member

jiangtj commented Jul 10, 2019

v=version, this is to prevent browser caching...

@1v9
Copy link
Member Author

1v9 commented Jul 10, 2019

@jiangtj Yes I know, just an option for some weird user like me.

@stevenjoezhang
Copy link
Contributor

In fact, setting HTTP headers through the server is the most effective way to manage the cache...
I'm not sure this feature is necessary

@stevenjoezhang stevenjoezhang self-requested a review July 10, 2019 17:30
@1v9 1v9 closed this Jul 10, 2019
@1v9 1v9 deleted the querystring branch July 10, 2019 17:31
@1v9 1v9 removed this from the v7.3.0 milestone Jul 10, 2019
@theme-next theme-next locked as resolved and limited conversation to collaborators Jul 10, 2019
@stevenjoezhang stevenjoezhang restored the querystring branch October 18, 2019 16:59
@theme-next theme-next unlocked this conversation Oct 18, 2019
@stevenjoezhang
Copy link
Contributor

It's not necessary to use query string to prevent browser caching

$ curl -I https://mi.js.org/js/local-search.js?v=7.4.1
HTTP/2 200 
date: Fri, 18 Oct 2019 17:01:22 GMT
content-type: application/javascript; charset=utf-8
set-cookie: __cfduid=d79f075be4ed309369d4ef4cc2a84fdd31571418082; expires=Sat, 17-Oct-20 17:01:22 GMT; path=/; domain=.js.org; HttpOnly
last-modified: Tue, 01 Oct 2019 13:16:50 GMT
etag: W/"5d9351c2-2a5e"
access-control-allow-origin: *
expires: Fri, 18 Oct 2019 17:10:58 GMT
cache-control: max-age=600
x-proxy-cache: MISS
x-github-request-id: 0F14:1719:4EE10F:6760DC:5DA9EFC9
via: 1.1 varnish
age: 25
x-served-by: cache-lax8649-LAX
x-cache: HIT
x-cache-hits: 1
x-timer: S1571418083.740795,VS0,VE1
vary: Accept-Encoding
x-fastly-request-id: 95b96bf520e907134b77ef1652537e0ac7dbf58a
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 527c12e8f88776ce-LAX

$ curl -I https://theme-next.org/js/local-search.js?v=7.4.1
HTTP/2 200 
accept-ranges: bytes
cache-control: public, max-age=0, must-revalidate
content-length: 10814
content-type: application/javascript
date: Fri, 18 Oct 2019 17:02:17 GMT
etag: "a02f9d7291f8cfb99713dda481f3decb-ssl"
strict-transport-security: max-age=31536000
age: 0
server: Netlify
x-nf-request-id: 17a1c02e-1c5f-41f9-b6ca-dcdc1c28561b-1915334

@1v9 1v9 changed the title Allow the deletion of query strings Delete query strings Oct 19, 2019
@1v9 1v9 added this to the v7.5.0 milestone Oct 19, 2019
@stevenjoezhang
Copy link
Contributor

@jiangtj How do you like it?

@jiangtj
Copy link
Member

jiangtj commented Oct 19, 2019

是的,header可以设置缓存时间,但假如文件更新了(文件名不变),但缓存时间未到期,浏览器获取的文件是本地的缓存文件(旧),还是服务器端(新)的呢?

Yes, header can set the cache time, but if the file is updated (the file name remains the same), but the cache time does not expire, is the file obtained by the browser a local cache file (old) or server-side (new)?

@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Oct 19, 2019

这两个例子中cache-control的时间都很短(0和600)。除非是用户自己用apache/nginx部署,并且把缓存时间设置为一个较大值(>1周),否则不会出现你说的情况。
目前这些服务商都会设置etag头,这样使用HTTP/2 + 304状态码效果明显好于query string。

@stevenjoezhang
Copy link
Contributor

stevenjoezhang commented Oct 19, 2019

jsDelivr对于github资源的cache-control默认是一周

$ curl -I https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js
HTTP/2 200 
date: Sat, 19 Oct 2019 19:03:32 GMT
content-type: application/javascript; charset=utf-8
content-length: 88145
access-control-allow-origin: *
access-control-expose-headers: *
timing-allow-origin: *
cache-control: public, max-age=604800, s-maxage=43200
x-content-type-options: nosniff
strict-transport-security: max-age=31536000; includeSubDomains; preload
etag: W/"15851-iFI5JDUbrAtdVg/gxXgeJVbnaT0"
accept-ranges: bytes
x-served-by: cache-ams21029-AMS, cache-hkg17920-HKG
age: 1
x-via: 1.1 VMtwzhdxjw169:4 (Cdn Cache Server V2.0), 1.1 VMtwzhdxnp201:1 (Cdn Cache Server V2.0)

cloudflare会继承用户设置,如果用作github.io的CDN服务,也有cache-control: max-age=600

@1v9
Copy link
Member Author

1v9 commented Oct 20, 2019

So, provide an option, like long long ago I did...

@jiangtj
Copy link
Member

jiangtj commented Oct 21, 2019

这两个例子中cache-control的时间都很短(0和600)。除非是用户自己用apache/nginx部署,并且把缓存时间设置为一个较大值(>1周),否则不会出现你说的情况。
目前这些服务商都会设置etag头,这样使用HTTP/2 + 304状态码效果明显好于query string。

一旦本地缓存命中,不会请求服务器的,所以假如cache时间是一周,那么当你更新主题之后,你的博客用户可能在1周内遇到由于js或css未更新而导致的问题

@1v9
Copy link
Member Author

1v9 commented Oct 23, 2019

@stevenjoezhang @jiangtj Merge or not?

@jiangtj
Copy link
Member

jiangtj commented Oct 23, 2019

merge, 3 > 1 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants