cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

Adding Expires Headers In Ruby On Rails

Whenever a first-time visitor visits your page, it may take several HTTP requests before the web page finish loading. To speed up your website, it helps to use Expires header to make any web page components cachaeble. By doing this, you can avoid any unnecessary HTTP requests on subsequent page views. Expires headers are most often used with images but it is still highly recommended that they also be used on ALL components such scripts, stylesheets, and Flash as well.

So here’s a nice short snippet from Mohit Jain that lets you add expires headers to assets in Ruby on Rails:

config.static_cache_control = "public, max-age=31536000"  # in production.rb file     

And in your file:

require ::File.expand_path('../config/environment',  __FILE__)
use Rack::Deflater
run YourApplicationName::Application

Actually, there are many ways to do this but this one in particular can be very helpful, especially in cases where you want to add expiry headers to assets hosted on Heroku.

(Image credit for parking meter:

Related Posts

Adding Instagram Badges to Your WordPress Profile

How to Create a Custom WordPress Registration Form with Flat UI

How to Create A Basic Hipster-Style Layout

How to Style Nav Links Using Floats With HTML5 and CSS3