V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Andy1999
V2EX  ›  问与答

同一个文件, Safari 返回和 Chrome 返回不一致?

  •  
  •   Andy1999 · 2016-03-26 20:11:54 +08:00 · 3315 次点击
    这是一个创建于 3156 天前的主题,其中的信息可能已经有所发展或是发生改变。

    简直 Exciting!

    还有为什么部分 css 不能被替换,已经在后端禁用 gzip 了

    location /fonts { 
    		proxy_pass https://fonts.googleapis.com/;
    		proxy_redirect off;
    		proxy_set_header Accept-Encoding ''; 
    		subs_filter_types text/css text/xml application/x-javascript;
    		sub_filter_once off;
    		subs_filter fonts.gstatic.com cdn.moefont.com/gstatic;
                    }
    

    更加奇怪的是部分能替换,部分不能

    https://cdn.moefont.com/fonts/earlyaccess/notosanssc.css 可以

    https://cdn.moefont.com/fonts/css?family=Source+Sans+Pro 这个就不行

    29 条回复    2016-03-27 20:15:27 +08:00
    ZGLHHH
        1
    ZGLHHH  
       2016-03-26 20:19:52 +08:00
    VmuTargh
        2
    VmuTargh  
       2016-03-26 20:20:22 +08:00 via Android   ❤️ 1
    你应该说: 简直 Excited! 这才是正确读法←_←
    kn007
        3
    kn007  
       2016-03-26 20:21:02 +08:00
    我这边都有被替换。
    chrome 。或许你那边 cache 了?
    Andy1999
        4
    Andy1999  
    OP
       2016-03-26 20:43:51 +08:00 via iPhone
    kn007
        5
    kn007  
       2016-03-26 20:54:11 +08:00
    @Andy1999 cdn 问题?

    IP : 113.107.238.19

    Andy1999
        6
    Andy1999  
    OP
       2016-03-26 20:57:35 +08:00 via iPhone
    @kn007 我擦 看到的内容都不一致
    kn007
        7
    kn007  
       2016-03-26 20:58:39 +08:00
    @Andy1999 就是就是,我觉得会不会你挂 VPN 的原因,解析的 CDN 服务器上的内存 cache 的不对?
    你那几台服务器或许需要集体 clean 下,或者对现在错的 ip 所属 clean 。。
    Andy1999
        8
    Andy1999  
    OP
       2016-03-26 21:05:52 +08:00 via iPhone
    @kn007 不行啊 SLB 真的太多了 我挂的是 Surge 我在查查
    aofall
        9
    aofall  
       2016-03-26 21:07:58 +08:00
    访问的地址是可以根据浏览器来判断、加载不同 css 以加载不同格式的字体

    https://fonts.googleapis.com/css?family=Kavoon

    用 Chrome 访问返回 woff2 格式的字体

    IE 访问返回 woff 格式的字体

    etc.
    kn007
        10
    kn007  
       2016-03-26 21:08:18 +08:00
    @Andy1999 你查查,有事联系。。

    @Livid 一直收不到 @Andy1999 的回复提醒。
    Andy1999
        11
    Andy1999  
    OP
       2016-03-26 21:14:49 +08:00
    @aofall 对,已经发现了这个问题,正在看空 UA 他会返回什么
    VmuTargh
        12
    VmuTargh  
       2016-03-26 22:40:29 +08:00
    noysk_000@WINDOWS-QU992AO MINGW32 ~
    $ curl -v https://cdn.moefont.com/fonts/css?family=Source+Sans+Pro
    * STATE: INIT => CONNECT handle 0x200482f0; line 1103 (connection #-5000)
    * Added connection 0. The cache now contains 1 members
    * Trying 119.147.33.20...
    * STATE: CONNECT => WAITCONNECT handle 0x200482f0; line 1156 (connection #0)
    * Connected to cdn.moefont.com (119.147.33.20) port 443 (#0)
    * STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x200482f0; line 1253 (connection #0)
    * ALPN, offering http/1.1
    * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
    * successfully set certificate verify locations:
    * CAfile: /usr/ssl/certs/ca-bundle.crt
    CApath: none
    * TLSv1.2 (OUT), TLS header, Certificate Status (22):
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * STATE: SENDPROTOCONNECT => PROTOCONNECT handle 0x200482f0; line 1267 (connection #0)
    * TLSv1.2 (IN), TLS handshake, Server hello (2):
    * NPN, negotiated HTTP1.1
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
    * TLSv1.2 (OUT), TLS handshake, Unknown (67):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS change cipher, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / AES256-GCM-SHA384
    * ALPN, server did not agree to a protocol
    * Server certificate:
    * subject: OU=Domain Control Validated; CN=*.moefont.com
    * start date: Sep 29 14:43:18 2015 GMT
    * expire date: Sep 29 14:43:18 2016 GMT
    * subjectAltName: cdn.moefont.com matched
    * issuer: C=BE; O=GlobalSign nv-sa; CN=AlphaSSL CA - SHA256 - G2
    * SSL certificate verify ok.
    * STATE: PROTOCONNECT => DO handle 0x200482f0; line 1288 (connection #0)
    > GET /fonts/css?family=Source+Sans+Pro HTTP/1.1
    > Host: cdn.moefont.com
    > User-Agent: curl/7.47.1
    > Accept: */*
    >
    * STATE: DO => DO_DONE handle 0x200482f0; line 1350 (connection #0)
    * STATE: DO_DONE => WAITPERFORM handle 0x200482f0; line 1477 (connection #0)
    * STATE: WAITPERFORM => PERFORM handle 0x200482f0; line 1487 (connection #0)
    * HTTP 1.1 or later with persistent connection, pipelining supported
    < HTTP/1.1 200 OK
    * Server nnws/1.7.3.6 is not blacklisted
    < Server: nnws/1.7.3.6
    < Date: Sat, 26 Mar 2016 14:27:38 GMT
    < Content-Type: text/css; charset=utf-8
    < Content-Length: 274
    < Connection: keep-alive
    < Cache-Control: private, max-age=86400
    < Expires: Sun, 27 Mar 2016 14:27:38 GMT
    < Content-Encoding: identity
    < Access-Control-Allow-Origin: *
    < Timing-Allow-Origin: *
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: SAMEORIGIN
    < X-XSS-Protection: 1; mode=block
    < Alternate-Protocol: 443:quic,p=1
    < Alt-Svc: quic=":443"; ma=2592000; v="31,30,29,28,27,26,25"
    < X-Daa-Tunnel: hop_count=1
    <
    @font-face {
    font-family: 'Source Sans Pro';
    font-style: normal;
    font-weight: 400;
    src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url( https://fonts.gstatic.com/s/sourcesanspro/v9/ODelI1aHBYDBqgeIAH2zlNzbP97U9sKh0jjxbPbfOKg.ttf) format('truetype');
    }
    * STATE: PERFORM => DONE handle 0x200482f0; line 1645 (connection #0)
    * Curl_done
    * Connection #0 to host cdn.moefont.com left intact




    Vivaldi 1.0.430.3:


    Firefox 43.0:


    Firefox 43.0 with Chrome UA:


    Firefox 43.0 with Edge UA:


    Firefox 43.0 with iPhone3.0 UA:


    Firefox 43.0 with Safari UA:
    VmuTargh
        13
    VmuTargh  
       2016-03-26 22:42:28 +08:00
    空 UA:
    @font-face {
    font-family: 'Source Sans Pro';
    font-style: normal;
    font-weight: 400;
    src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url( https://fonts.gstatic.com/s/sourcesanspro/v9/ODelI1aHBYDBqgeIAH2zlNzbP97U9sKh0jjxbPbfOKg.ttf) format('truetype');
    }
    Andy1999
        14
    Andy1999  
    OP
       2016-03-26 22:44:17 +08:00 via iPhone
    @VmuTargh 是的,已经做了 UA 判断(≧∇≦)

    目前就一个问题了 为什么有些替换得了 有些不行
    VmuTargh
        15
    VmuTargh  
       2016-03-26 22:45:38 +08:00
    @Andy1999 我觉着应该是 CDN 或者谷歌的锅......
    konakona
        16
    konakona  
       2016-03-26 22:53:15 +08:00
    哼,可恶,为什么你屏幕那么大!
    VmuTargh
        17
    VmuTargh  
       2016-03-26 23:01:57 +08:00
    @Andy1999 http://diylighttpd-vtkg.rhcloud.com/gfonts/css?family=Source+Sans+Pro
    你丫参数写错了吧
    报错信息:
    nginx: [emerg] unknown directive "subs_filter" in /var/lib/openshift/xx/app-root/data//nginx/conf/nginx.conf:57
    An error occurred executing 'gear start' (exit code: 1)
    Error message: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/xx/diy
    VmuTargh
        18
    VmuTargh  
       2016-03-26 23:05:42 +08:00
    Andy1999
        19
    Andy1999  
    OP
       2016-03-26 23:31:19 +08:00 via iPhone
    @VmuTargh 这需要额外的模块啊…
    你是怎么替换的 但是如果不用这个,用 Nginx 默认的替换模块只能替换一次
    VmuTargh
        20
    VmuTargh  
       2016-03-26 23:33:30 +08:00
    @Andy1999 Nginx 1.9.12 Mainline
    手动编译, --with-http_sub_module
    VmuTargh
        21
    VmuTargh  
       2016-03-26 23:37:27 +08:00
    @Andy1999 哦, 我突然想起有个东西叫做 openresty......
    indust
        22
    indust  
       2016-03-26 23:42:46 +08:00   ❤️ 1
    @VmuTargh
    subs_filter 是这个第三方模块的命令 https://github.com/yaoweibin/ngx_http_substitutions_filter_module
    sub_filter 才是官方 http_sub_module 模块的
    Andy1999
        23
    Andy1999  
    OP
       2016-03-27 12:22:24 +08:00
    @VmuTargh
    @indust 你的 nginx.conf 能否贴出来
    Andy1999
        24
    Andy1999  
    OP
       2016-03-27 12:22:38 +08:00
    @indust 对的,貌似官方的只能替换一次
    VmuTargh
        25
    VmuTargh  
       2016-03-27 12:49:18 +08:00
    indust
        26
    indust  
       2016-03-27 15:37:56 +08:00   ❤️ 1
    有些文件不会被替换应该是这个第三方模块的问题 https://github.com/yaoweibin/ngx_http_substitutions_filter_module/blob/master/ngx_http_subs_filter_module.c#L248
    如果响应头里 Content-Encoding 是 identity 的话就会被当成压缩内容不作处理
    官方的模块没有这个问题, 但只是字符替换的话局限性太大
    VmuTargh
        27
    VmuTargh  
       2016-03-27 16:58:41 +08:00
    @indust 我丫现在就觉着有点问题了, earlyaccess 的 font-url 默认是'//xxx.com'而不是按照请求自动适配来的......
    Andy1999
        29
    Andy1999  
    OP
       2016-03-27 20:15:27 +08:00 via iPhone
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1078 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 19:22 · PVG 03:22 · LAX 11:22 · JFK 14:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.