前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >解决Octopress博客访问慢的问题

解决Octopress博客访问慢的问题

作者头像
技术小黑屋
发布2018-09-04 16:42:30
1K0
发布2018-09-04 16:42:30
举报
文章被收录于专栏:技术小黑屋技术小黑屋

解决Octopress博客访问慢的问题

本博情况

必不可少的罗嗦

买了这个域名已经一周了,已经决定博客的面向群体为汉语用户。但是发现国内访问还是超级慢,慢的让人无法接收了,当然具体原因,大家都懂得。没办法,尝试使用过安全宝,速度并没有明显替身,反而搜索引擎收录加少了,遂弃用。于是只好自己修改Octopress程序了。修改之前的访问速度以分钟计数。修改完成之后,秒开了有木有。

清理没用的服务

以下修改均修改_config.yml,以下可以根据自己的需要进行去除。

去除Disqus评论

去除上面红色区域的部分,打开文件找到Disqus Comments,按照下面在每一行前面加#注释掉即可。

1 2 3

# Disqus Comments #disqus_short_name: androidyue #disqus_show_comment_count: true

去掉Github仓库展示

1 2 3 4 5

# Github repositories #github_user: androidyue #github_repo_count: 11 #github_show_profile_link: true #github_skip_forks: true

去除Twitter按钮

1 2 3

# Twitter #twitter_user: #twitter_tweet_button: true

去除Google+相关

1 2 3 4 5 6 7 8

# Google +1 #google_plus_one: true #google_plus_one_size: medium # Google Plus Profile # Hidden: No visible button, just add author information to search results #googleplus_user: 105362551238192049560 #googleplus_hidden: false

去除Pinboard服务

1 2 3

# Pinboard #pinboard_user: #pinboard_count: 3

去除Delicious评论,去除后可能没有评论系统

1 2 3

# Delicious #delicious_user: #delicious_count: 3

去除Facebook Like

1 2

# Facebook Like #facebook_like: true

替换快速的请求资源

其实,真正解决加速的重要环节可能是这里,因为Octopress很多依赖于Google的库和资源。

解决Google Analytics巨慢的问题

对于使用Google Analytics来说,加在ga.js这个文件简直是要命的慢,这里我使用自己存放在七牛CDN上的js.http://droidyue-tools.qiniudn.com/ga.js 已验证,完全可以正常收集数据。 参考如下,修改source/_includes/google_analytics.html

1 2 3 4 5 6 7 8

_gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src='http://droidyue-tools.qiniudn.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>

解决fonts.googleapis.com蜗牛慢

这里我们使用数字公司提供的Google Fonts大陆解决方案,使用fonts.useso.com替换fonts.googleapis.com。 修改文件/source/_includes/custom/head.html

1 2 3

<!--Fonts from Google"s Web font directory at http://google.com/webfonts --> <link href="http://fonts.useso.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css"> <link href="http://fonts.useso.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">

解决ajax.googleapis.com慢的问题

修改source/_includes/head.html

1 2 3 4 5 6

<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css"> <link href="/atom.xml" rel="alternate" title="技术小黑屋" type="application/atom+xml"> <script src="/javascripts/modernizr-2.0.js"></script> <script src="//ajax.useso.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script>!window.jQuery && document.write(unescape('%3Cscript src="./javascripts/lib/jquery.min.js"%3E%3C/script%3E'))</script> <script src="/javascripts/octopress.js" type="text/javascript"></script>

In Conclusion

导致网站慢的原因其实是加载Google的资源,当然我们不能怨Google.经过测试,使用数字公司的解决方法之后,国内国外访问速度都是可以的。这里还是推荐以下数字公司的这个解决方案http://libs.useso.com/

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 本博情况
  • 必不可少的罗嗦
  • 清理没用的服务
    • 去除Disqus评论
      • 去掉Github仓库展示
        • 去除Twitter按钮
          • 去除Google+相关
            • 去除Pinboard服务
              • 去除Delicious评论,去除后可能没有评论系统
                • 去除Facebook Like
                • 替换快速的请求资源
                  • 解决Google Analytics巨慢的问题
                    • 解决fonts.googleapis.com蜗牛慢
                      • 解决ajax.googleapis.com慢的问题
                      • In Conclusion
                      相关产品与服务
                      内容分发网络 CDN
                      内容分发网络(Content Delivery Network,CDN)通过将站点内容发布至遍布全球的海量加速节点,使其用户可就近获取所需内容,避免因网络拥堵、跨运营商、跨地域、跨境等因素带来的网络不稳定、访问延迟高等问题,有效提升下载速度、降低响应时间,提供流畅的用户体验。
                      领券
                      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档