App Engine花费更长的时间(> 1秒)为静态JS提供静态CSS [英] App Engine taking Far Longer (> 1 sec) to serve static JS than static CSS
问题描述
这个文件是20kb。它始终服务> 1秒。
http://www.adrenalinemobility.com/js/ss-symbolicons.js
这是同一个文件 .css,因为它是扩展名:
http://www.adrenalinemobility.com/js/ss-symbolicons.css
它服务几乎整整快一秒。
这是我的app.yaml:
$ - name:jinja2
版本:latest
处理程序:
- url:/favicon\.ico
static_files:assets / favicon.ico
上传:assets / favicon\.ico
- url:/ css
static_dir:assets / css
$ b - url:/ img
static_dir:assets / img
- url:/ js
static_dir:assets / js
- url:/.*
script:web.APP
我也试过这个 s
- url: /js/ss-symbolicons.js
static_files:assets / js / ss-symbolicons.js
upload:assets / js / ss-symbolicons.js
我观察到的方式:
$ b 这里有一个webpagetest瀑布图来说明这个问题 - 注意一个文件有一个巨大的TTFB: http://www.webpagetest.org/result/131101_ZQ_ZGQ/1/details/
如果我手动将mime_type设置为文本
,那么它运行得很快。 application / javascript
, application / x-javascript
, text / javascript
都很慢。目前,如果您想测试,这些文件不需要手动指定MIME类型。
更多信息,请参见jchu:
慢速版的服务内容为: Content-Length:19973
,快速版的服务于: Transfer-Encoding:chunked
更多细节:
我通常会得到服务器 74.125 .28.121
。 reddit上的某个人获得了服务器 173.194.71.121
,它们之间似乎甚至有服务速度。所以也许它是服务器/位置相关的?
< a href =http://pastebin.com/raw.php?i=Bh0TwHix =nofollow noreferrer>这是另一个pastebin,其中只有来自每个文件的十个请求的时序信息处于紧密循环中
将mime_type:text添加到您的JavaScript静态资源中。需要看看mime_type是什么,假设是什么聪明的技巧正在做的文本VS其他MIME类型......
(Question edited b/c I have realized it involves file type)
This file is 20kb. It is consistently taking > 1 second to serve.
http://www.adrenalinemobility.com/js/ss-symbolicons.js
Here is the same file with .css as it's extension:
http://www.adrenalinemobility.com/js/ss-symbolicons.css
It serves almost 1 whole second faster.
Here is my app.yaml:
application: adrenaline-website
version: 1
api_version: 1
runtime: python27
threadsafe: true
libraries:
- name: jinja2
version: latest
handlers:
- url: /favicon\.ico
static_files: assets/favicon.ico
upload: assets/favicon\.ico
- url: /css
static_dir: assets/css
- url: /img
static_dir: assets/img
- url: /js
static_dir: assets/js
- url: /.*
script: web.APP
I've also tried this static_files
line (before the /js handler), and it was slow too:
- url: /js/ss-symbolicons.js
static_files: assets/js/ss-symbolicons.js
upload: assets/js/ss-symbolicons.js
Ways I have observed this:
- Chrome, Firefox (both on Linux) - from a DSL connection in Silicon Valley
- wget, curl, etc from that machine.
- Remotely wget and curl from a high-speed server at the University of Illinois
- Remote web testing services like webpagetest (see below):
Here's a webpagetest waterfall graph that illustrates this problem - notice the one file has a huge TTFB: http://www.webpagetest.org/result/131101_ZQ_ZGQ/1/details/
If i manually set the mime_type to text
, then it goes fast. application/javascript
, application/x-javascript
, text/javascript
are all slow. Currently those files are serving without manually specified mime-type if you wish to test.
Some more info, as noticed by jchu:
The slow version serves with: Content-Length: 19973
and the fast version serves with: Transfer-Encoding: chunked
Still more details:
I usually get server 74.125.28.121
. Someone on reddit got server 173.194.71.121
and it seems to have even serving speeds between them. So maybe it's server/location dependent?
Here is a pastebin with full curl logs of requests for both files
Add mime_type: text to your JavaScript static resource.
Would need to look into what mime_type is being assumed, what what clever trick is being done for text vs other mime types...
这篇关于App Engine花费更长的时间(> 1秒)为静态JS提供静态CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!