依照慣例是_count結尾,型別是integer,有預設值0。
How to build your own CDN with Kubernetes - Insight Data - 0 views
Ruby on Rails 實戰聖經 | 網站效能 - 0 views
- ...19 more annotations...
-
如果要讓你的Assets例如CSS, JavaScript, Images也讓使用者透過CDN下載,只要修改config/environments/production.rb的config.action_controller.asset_host為CDN網址即可。
Asset Pipeline - Ruby on Rails 指南 - 0 views
-
清单文件或帮助方法
- ...36 more annotations...
-
程序中使用了 jQuery 代码库和许多模块,都保存在 lib/assets/javascripts/library_name 文件夹中,那么 lib/assets/javascripts/library_name/index.js 文件的作用就是这个代码库的清单。清单文件中可以按顺序列出所需的文件,或者干脆使用 require_tree 指令。
-
require_tree 指令告知 Sprockets 递归引入指定文件夹中的所有 JavaScript 文件。文件夹的路径必须相对于清单文件。也可使用 require_directory 指令加载指定文件夹中的所有 JavaScript 文件,但不会递归。
-
不管创建新程序时有没有指定 --skip-sprockets 选项,Rails 4 都会生成 app/assets/javascripts/application.js 和 app/assets/stylesheets/application.css
-
如果用 CDN 分发静态资源,要确保文件不会被缓存,因为缓存会导致问题。如果设置了 config.action_controller.perform_caching = true,Rack::Cache 会使用 Rails.cache 存储静态文件,很快缓存空间就会用完。
-
为 Rails 提供标准 JavaScript 代码库的 jquery-rails gem 是个很好的例子。这个 gem 中有个引擎类,继承自 Rails::Engine。添加这层继承关系后,Rails 就知道这个 gem 中可能包含静态资源文件,会把这个引擎中的 app/assets、lib/assets 和 vendor/assets 三个文件夹加入 Sprockets 的搜索路径中。
Viral JS - 0 views
The Asset Pipeline - Ruby on Rails Guides - 0 views
-
adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass and ERB
- ...80 more annotations...
-
Starting with version 3.1, Rails defaults to concatenating all JavaScript files into one master .js file and all CSS files into one master .css file
-
In production, Rails inserts an MD5 fingerprint into each filename so that the file is cached by the web browser
-
The technique sprockets uses for fingerprinting is to insert a hash of the content into the name, usually at the end.
-
The sass-rails gem is automatically used for CSS compression if included in Gemfile and no config.assets.css_compressor option is set.
-
When a filename is unique and based on its content, HTTP headers can be set to encourage caches everywhere (whether at CDNs, at ISPs, in networking equipment, or in web browsers) to keep their own copy of the content
-
app/assets is for assets that are owned by the application, such as custom images, JavaScript files or stylesheets.
-
lib/assets is for your own libraries' code that doesn't really fit into the scope of the application or those libraries which are shared across applications.
-
vendor/assets is for assets that are owned by outside entities, such as code for JavaScript plugins and CSS frameworks.
-
By default these files will be ready to use by your application immediately using the require_tree directive.
-
By default, this means the files in app/assets take precedence, and will mask corresponding paths in lib and vendor
-
if you add an erb extension to a CSS asset (for example, application.css.erb), then helpers like asset_path are available in your CSS rules
-
If you add an erb extension to a JavaScript asset, making it something such as application.js.erb, then you can use the asset_path helper in your JavaScript code
-
data URI — a method of embedding the image data directly into the CSS file — you can use the asset_data_uri helper.
-
Sprockets will also look through the paths specified in config.assets.paths, which includes the standard application paths and any paths added by Rails engines.
-
sass-rails provides -url and -path helpers (hyphenated in Sass, underscored in Ruby) for the following asset classes: image, font, video, audio, JavaScript and stylesheet.
-
The require_tree directive tells Sprockets to recursively include all JavaScript files in the specified directory into the output.
-
manifest files contain directives — instructions that tell Sprockets which files to require in order to build a single CSS or JavaScript file.
-
Directives are processed top to bottom, but the order in which files are included by require_tree is unspecified.
-
You need not supply the extensions explicitly. Sprockets assumes you are requiring a .js file when done from within a .js file
-
Rails 4 creates both app/assets/javascripts/application.js and app/assets/stylesheets/application.css regardless of whether the --skip-sprockets option is used when creating a new rails application.
-
Additional layers of preprocessing can be requested by adding other extensions, where each extension is processed in a right-to-left manner
-
In development mode, assets are served as separate files in the order they are specified in the manifest file.
-
when these files are requested they are processed by the processors provided by the coffee-script and sass gems and then sent back to the browser as JavaScript and CSS respectively.
-
By default Rails assumes that assets have been precompiled and will be served as static assets by your web server
-
If you set config.assets.initialize_on_precompile to false, be sure to test rake assets:precompile locally before deploying
-
By default Rails assumes assets have been precompiled and will be served as static assets by your web server.
-
The X-Sendfile header is a directive to the web server to ignore the response from the application, and instead serve a specified file from disk