![](http://habrastorage.org/getpro/habr/avatars/808/6b1/50c/8086b150c7867bb121c2882472a113ec.jpg)
3 simple tips that will make your Rails application faster, part # 2
We continue to optimize our applications written in Ruby on Rails. The first part of the article here
Tip # 1: Get your static content
Tip # 2: Remove all unnecessary
Tip # 3: Cache the entire page
Tip # 2: Remove all unnecessary
Authentication, access to sessions, verification of user rights and unnecessary database queries. Do you really need to do all this with every request to the server?
You can disconnect sessions from specific Actions simply by specifying: This significantly improves performance and is an excellent alternative for caching if you need to access the database but do not need to verify user rights.
If you use RestfulAuthentication or ActsAsAuthenticated plugins, you can disable user rights checking for some Actions, which will save you a single database request.
or
well, or whatever else you have ...
Using fragment caching for your Partials, skip the database queries in your controller via read_fragment. Also, do not forget to use the option: include in your queries to load associations. This will reduce the number of queries by 2 times
Tip # 1: Get your static content
Tip # 2: Remove all unnecessary
Tip # 3: Cache the entire page
Tip # 2: Remove all unnecessary
Authentication, access to sessions, verification of user rights and unnecessary database queries. Do you really need to do all this with every request to the server?
You can disconnect sessions from specific Actions simply by specifying: This significantly improves performance and is an excellent alternative for caching if you need to access the database but do not need to verify user rights.
session :off, :only => :index
If you use RestfulAuthentication or ActsAsAuthenticated plugins, you can disable user rights checking for some Actions, which will save you a single database request.
skip_filter :login_from_cookie
or
skip_filter :login_required
well, or whatever else you have ...
Using fragment caching for your Partials, skip the database queries in your controller via read_fragment. Also, do not forget to use the option: include in your queries to load associations. This will reduce the number of queries by 2 times
@users = User.find('all) unless read_fragment(’unique_cache_key’)
Post.find(:all, :include => :user)