ITeye博客

rails缓存Tips: 缓存js,css文件

johnnyhg · 2009-12-26 23:52 · Ruby && RoR · 编程语言 · Cache · CSS · Rails · JavaScript · Markdown

4.缓存Tips: 缓存js,css文件

请参考: http://railslab.newrelic.com/2009/01/22/page-responsiveness


# Combining all your javascripts in production mode


<%=
 javascript_include_tag
 :all
,
 :cache
 =>
 true
 %>



<%=
 javascript_include_tag
 :all
,
 :cache
 =>
 "main"
 %>



<%=
 javascript_include_tag
 "product"
,
 "cart"
,
 "checkout"
,
 :cache
 =>
 "shop"
 %>


 

# Same sort of stuff with stylesheets


<%=
 stylesheet_link_tag
 :all
,
 :cache
 =>
 true
 %>


 

# Declaring an asset host

ActionController::Base.asset_host = "assets.example.com"

 

# What uses the asset host url


<%=
 image_tag
 'title.gif'
 %>



<%=
 javascript_include_tag
 :all
 %>



<%=
 stylesheet_link_tag
 :all
 %>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。