Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 184675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:20:03+00:00 2026-05-11T15:20:03+00:00

My Rails application is running on a VM. The VM’s performance is just fine

  • 0

My Rails application is running on a VM. The VM’s performance is just fine with static pages. In fact, I’m running another site using Apache virtual hosting that is just serving up static HTML files and the response is adequate. However, my Rails application that is dynamically generating XML files responds very slowly. In fact, it takes about 10 seconds or so for each XML file. These XML files that Rails generates do not change more than once a day.

What is the best practice to configure these XML files to be cached?

Edit 1:

I should mention that these XML files are not viewed by a browser. They are viewed by mobile applications in the ‘field.’ So, unfortunately sending ‘HTTP/1.0 304 not modified’ won’t work.

Edit 2:

If it matters, I’m using Phusion Passenger to host my Rails app.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:20:03+00:00Added an answer on May 11, 2026 at 3:20 pm

    If you’re using rails’ static page caching and serving through apache, just using an explicit xml extension on the urls would do it.

    if you’re only serving xml and no html you might also edit the apache conf to default to xml instead of html when looking for cached files.

    cache expiry is a rather boring thing to code and test, but since you’re seldom regenerating the files, you might just expire the entire cache.


    Here’s a trimmed selection of files and excerpts from how I handle cache in a small, seldom updated rails site:

    In the controllers you want to cache

    class XmlThingController < ApplicationController   caches_page :index, :show, :other_actions 

    In the controllers/actions that modify data that would cause changes to the xmls:

    class Admin::SomeCrudController < AppplicationController   cache_sweeper :stupid_master_sweeper, :only => [ :save, :destroy ] 

    In ‘config/environments/production.rb’

    config.action_controller.page_cache_directory =    File.join(RAILS_ROOT, 'public', 'cache') 

    Somehere in your vhost apache conf:

    # 1.4. Handle caching  # 1.4.1. prevent direct cache access RewriteRule  ^/cache - [F,L]  # 1.4.2. for index RewriteCond  %{DOCUMENT_ROOT}/cache/index.html -f RewriteRule  ^/?$ /cache/index.html [L]  # 1.4.3. for explicitly specified extensions RewriteCond  %{DOCUMENT_ROOT}/cache%{REQUEST_URI} -f RewriteRule  ^(.*)$ /cache$1 [L]  # 1.4.4. with html extension implied RewriteCond  %{DOCUMENT_ROOT}/cache%{REQUEST_URI}.html -f RewriteRule  ^(.*)$ /cache$1.html [L]   # 1.5. Finally, proxy everything else to mongrel RewriteCond  %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule  ^/(.*)$ balancer://your-website-proxy%{REQUEST_URI} [P,QSA,L] 

    The dumb sweeper that cleans that entire cache every time it’s triggered:

    class StupidMasterSweeper < ActiveRecord::Observer   observe Foo, Bar # All models that affect caching here    def after_save(record); end   def after_destroy(record); end    def filter(controller)     # sweep everything.     `cd #{RAILS_ROOT} && RAILS_ENV=#{ENV['RAILS_ENV']} rake cache:clear`   end end 

    lib/tasks/cache.rake

    namespace :cache do     desc 'Remove all cached files'    task :clear do     puts `rm -rf #{RAILS_ROOT}/public/cache/*`   end   end  

    If you prefer to default the default implied extension to xml, change the extension on the 1.4.2 index rule, and the following:

    # 1.4.4. with html extension implied RewriteCond  %{DOCUMENT_ROOT}/cache%{REQUEST_URI}.html -f RewriteRule  ^(.*)$ /cache$1.html [L] 

    to:

    # 1.4.4. with xml extension implied RewriteCond  %{DOCUMENT_ROOT}/cache%{REQUEST_URI}.xml -f RewriteRule  ^(.*)$ /cache$1.xml [L] 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Apache + passenger for my rails application, The application is running fine
am running apache(2.2.11) as frontend server to mongrel and using rails application trying to
We're using EngineYard Cloud to deploy our Ruby on Rails application. We are running
I have a Rails application running on Rails 2.3.9. It runs fine with ruby
If I have a Ruby on Rails application running on my Apache shared server
I have site running rails application and resque workers running in production mode, on
I'm running a rails application on EC2, and I'm using mongoHQ as DBMS. I've
I am running my tests for a rails application using test/unit and capybara. I
When running unit and functional tests using rake, on a rails application, I notice
I am running a RoR application (rails 2.3.8, ruby 1.8.7), the application runs fine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.