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

  • SEARCH
  • Home
  • 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 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 a rails application running on a Linux server. I would like to
I have a Rails 2.0.2 application running with a postgresql db. The machine will
I have a Ruby on Rails application running on localhost:3000 . I would like
I am trying to get my rails application running on my web server, but
I've got a simple Rails application running as a splash page for a website
I have a rails application where each user has a separate database. (taking Joel
I have a rails application which is still showing the cachebusting numeric string at
I've got a rails application where users have to log in. Therefore in order

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.