Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby on rails 3.1 leverage browser caching

I have run in production mode my smart aplication in rails 3.1 with mongodb.

I can see that page speed from firebug have a smart problem:

leverage browser caching of static, you can see in the above image:

enter image description here

I have check this fix but not working for me:

ROR + MVC Disable Browser Cache

I want to know how can I fix this problem for my image, css and javascript, or if there is a gem for this.

like image 372
hyperrjas Avatar asked Dec 28 '22 10:12

hyperrjas


1 Answers

Thank you for their response Hightechrider and miaout17.

Im using apache. I add to apache2.conf the next code:

<LocationMatch "^/assets/.*$">
 # Some browsers still send conditional-GET requests if there's a
 # Last-Modified header or an ETag header even if they haven't
 # reached the expiry date sent in the Expires header.
 Header unset Last-Modified
 Header unset ETag
 FileETag None
 # RFC says only cache for 1 year
 ExpiresActive On
 ExpiresDefault "access plus 1 year"
</LocationMatch>

Bue I get the next error when I try reset my server apache:

Syntax error on line 256 of /etc/apache2/apache2.conf: Invalid command 'ExpiresActive', perhaps misspelled or defined by a module not included in the server configuration Action 'restart' failed. The Apache error log may have more information.

Some idea?

Edited I found the fix for this error:

If you have a ubuntu user You can take a shortcut using a2enmod, a command that enables the module for you automatically:

sudo a2enmod headers

and then restart your server and voila :D working fine.

like image 71
hyperrjas Avatar answered Jan 18 '23 19:01

hyperrjas