Topic: Using static file + apache to offload some traffic: bad idea?


I have an application that that manages widgets on other peoples sites via javascript included at the bottom of the other peoples sites.

In most cases, the widget is turned off. (It's a research tool.)

In the controller there is a action that turns the widget on and off. I've gotten huge performance gain by just making the "off" action create a file in app/public -- and thus if the file exists there is never a call to rails; the action is handled entirely by apache. The file served is empty.

The "on" action removes the file and then the request goes through to the controller like normal.

The problem is that users who are designing their widget need to be able to preview it (when they are signed into the application.) But now there is no way to preview a widget that is turned off. I can't write a separate method, or put in additional conditions to handle the preview case because the request never even gets to the controller.

Do I need to rethink my approach with apache or is there a way that I can use httpd.conf to pass a request to rails when a certain param is set? I'm thinking of proceeding with some type of rewrite condition based on "params[:mode] == preview", but I have no idea how to force apache to hand off a request to rails.

Thanks for any advice.

Re: Using static file + apache to offload some traffic: bad idea? … damnwidget -> normal users with the caching, public folder dealie … damnwidget -> design/admin users without caching

Also lets you put code just in the designers controller that restricts access. Lots easier to restict access per controller rather than per action in the controller.