Goldspike ignores static HTML Rails page caching
------------------------------------------------
Key: JRUBY-924
URL: http://jira.codehaus.org/browse/JRUBY-924
Project: JRuby
Issue Type: Improvement
Components: JRuby-extras
Affects Versions: JRuby 1.0.0RC1
Environment: Linux 2.6.20, Java 1.6
Reporter: Raphael Valyi
Assignee: Thomas E Enebo
RoR is very good at managing smat caches of your web app. Especially, the
fastest cache system is static html cache. You would for instance write:
{noformat}
caches_page :show
{noformat}
in your controller to store a cache of the show action.
The cache will then be stored as a file in your public directory (where is
deployed the web app when using JRuby, eg
glassfish/domains/domain1/applications/j2ee-modules/foo/public when using
Glassfish server) Webrick and Mongrel correctly serve that cache for the next
requests.
But for some reason, Goldspike fails to use that cache!! You can see that by
monitoring your RoR logs when you request such a cached page. A cached page
should not be re computed untill the cache is invalidated. Depending on how
expensive is your page to compute, the effect can be disastrous.
A workarround is to use an Apache frontal (or other) and use such a httpd.conf:
{noformat}
<VirtualHost *:80>
...
# Configure mongrel_cluster
<Proxy balancer://cluster_node>
BalancerMember http://127.0.0.1:8030
</Proxy>
RewriteEngine On
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://cluster_node%{REQUEST_URI} [P,QSA,L]
...
</VirtualHost>
{noformat}
( see http://www.railsenvy.com/2007/2/28/rails-caching-tutorial for details)
Still, a promiss of J2EE Rails deployement is to get rid of such tricky Apache
frontal administration. On Ubuntu Feisty, you would need to rebuild Apache from
non distro sources to get the that proxy balancer module working, which sucks A
LOT...
So finally, J2EE RoR will only faster and simpler to deploy when Goldspike will
correctly use the RoR cache.
Alternatively, you could use fragment caching instead of page caching but that
would be an order of magnitude slower...
Cheers,
Raphaƫl Valyi.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email