2013-11-25 79 views
0

我正在使用运行nginx + php-fpm的VPS。我的博客基于laravel.I试图优化我的网站以通过网页测试。我从缓存静态内容测试中获得了“C-(72/100)”。利用浏览器缓存静态资产(nginx)

我配置我的nginx的缓存:

# Set header expirations on per-project basis 
    location ~* \.(?:ico|css|js|gif|jpe?g|JPG|png|svg|woff)(\?ver=[0-9.]+)?$ { 
     root /home/ytsejam/public/sirtcantalilar.com/public; 
      expires 365d; 

      tcp_nodelay off; ## Set the OS file cache. 
      open_file_cache max=100 inactive=120s; 
      open_file_cache_valid 45s; 
      open_file_cache_min_uses 2; 
      open_file_cache_errors off; 
      add_header Pragma public; 
      add_header Cache-Control "public"; 
      log_not_found off; 

       } 

,但我得到了巨大的faillist:

FAILED - (No max-age or expires) - http://xslt.alexa.com/site_stats/js/s/a?url=sirtcantalilar.com 
FAILED - (No max-age or expires) - http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold 
FAILED - (No max-age or expires) - http://sirtcantalilar.com/assets/css/fonts/fontawesome-webfont.eot? 
FAILED - (No max-age or expires) - http://scontent-b-lga.xx.fbcdn.net/hphotos-frc3/s403x403/988772_225525044282988_738222852_n.jpg 
FAILED - (No max-age or expires) - http://sirtcantalilar.com/assets/css/fonts/BebasNeue-webfont.eot? 
FAILED - (No max-age or expires) - http://fonts.googleapis.com/css?family=Dosis:400,500,600,700&subset=latin,latin-ext 
FAILED - (No max-age or expires) - http://fonts.googleapis.com/css?family=Open+Sans:400,700italic,600italic,700,600,400italic 
FAILED - (No max-age or expires) - http://platform.twitter.com/embed/timeline.633fdd7a8cbe780bedb23434c948fe33.default.css 
FAILED - (No max-age or expires) - http://sirtcantalilar.com/assets/css/fonts/Entypo.eot? 
FAILED - (60 seconds) - http://external.ak.fbcdn.net/safe_image.php?d=AQC0yxqR5PAB_4uM&w=154&h=154&url=http%3A%2F%2Fsirtcantalilar.com%2Fuploads%2Fimg%2Fposts%2Fthumbnails%2F98%2Fthumb-Amsterdam_Light_Festival.jpg&cfs=1....... 

我如何优化缓存规则,为什么谷歌字体的API和Twitter不能使用浏览器缓存?

回答

0

您无法对从域/服务器外部提供服务的对象设置过期时间。为什么?因为网页测试与外部服务器“会谈”而不是您自己的服务器。

+0

+1我并没有让你失望,但无论谁做了什么都可能会期待更全面的解决方案。例如,错误是否意味着Google和Twitter资源在某种程度上被错误地使用?如果是这样,是否有解决方案?如果没有,测试是否有解决方法? –