Rails Page caching is just broken

December 30, 2005 Link to post  Permalink

I’ve been noticing 404 errors on my blog for pages that should be there. After digging around, I noticed that the page cache is getting in the way of delivering pages.

Here’s what I think is going on.

I have a page with a URL http://blog.craz8.com/articles/2005/10/26/typo-has-caching-issues.
I also have a page with a URL of http://blog.craz8.com/articles/2005/10/26 and one with a URL of http://blog.craz8.com/articles/2005/10.

If the page with the shorter URL is requested before the one with the longer URL, then the longer URL will return a 404. If the longer URL is requested first, then nothing bad happens.

All should be working

December 29, 2005 Link to post  Permalink

There was a DNS issue with blog.craz8.com that is now resolved, and Typo page caching has been a little tricky (since I’m not the owner of the generated cache files)

New host

December 28, 2005 Link to post  Permalink

My blog has moved to Planet Argon for hosting. If you can see this entry, then all is well!

Next: World Domination

December 27, 2005 Link to post  Permalink

For christmas, Lisa got me Electronic Gadgets for the Evil Genius This thing has plans (sadly, not detailed) for an EMP, just like in the movies!

My plans for World Domination are set in motion, bwah-ha-ha-ha.

Next on my list: Fluffy White Cat.

Rails action cache upgrade

December 26, 2005 Link to post  Permalink

Due to issues with page caching, I just started looking at the Rails action cache. There are a few things that could be done better by the built in code, but since this is written in Ruby, I can make those changes in my code and override the pieces I want.

The core of Rails Action Caching is the around filter applied to all actions that are to be cached. I re-implemented the before and after methods to make the changes I needed.

Here are the things I changed:

The code can be downloaded here. Place action-cache.rb in your lib directory and require ‘action-cache’ in your environment.rb to hook this in. Since this extends Rails Action Caching, all the documentation for that code still applies, e.g.

Rails OutputCompressionFilter

December 17, 2005 Link to post  Permalink

The Rails documentation has passing references to a filter class called OutputCompressionFilter. However, this code is nowhere to be found.

Since I have some code to do output compression (see my earlier post), I decided to repackage it as this class:

Here is the source file – put it in your lib directory.

Here is how you use this code:

Rails RJS Templates need better replace semantics

December 15, 2005 Link to post  Permalink

<!--adsense-->

If I have a collection of things that are output like this:

or

I can use AJAX to insert a new ‘thing’ by implementing an RJS template that does this, reusing the same partial layout:

Rails output compression

December 7, 2005 Link to post  Permalink

I want to be able to compress my output text that I send to the browser from my Rails app. This will include HTML, javascript, Ajax responses, plain text etc. Lighttpd will perform this function for the static files it serves, but not for the dynamic files, so I went looking for a solution.

There is a README for ActionPack that has this snippet of code:

after_filter { |c| c.response.body = GZip::compress(c.response.body) }

I added this to my ApplicationController, and it doesn’t work.

Make your DIVs Resizeable

December 1, 2005 Link to post  Permalink

<!--adsense-->

I love using Scriptaculous for its effects and drag/drop. However, I need to have my DIVs be resizable too. To make this happen, I’ve written a class called Resizeable that can be added to a DIV in the same way that Draggable can be.

This code is standalone (it needs Prototype, but not Scriptaculous), and it can be used with Draggable with one note: The Draggable handle cannot be the element that is Resizeable, you must specify a handle element when you create a Draggable to avoid confusion between Draggable and Resizeable.

This doesn’t work very well



new Draggable(‘foo’); new Resizeable(‘foo’);

This works nicely:



new Draggable(‘foo’, {handle: ’bar’}); new Resizeable(‘foo’);

There aren’t many options for this object, but here they are:

The grab areas can be defined with top, left, bottom, right. Each defaults to 6 pixels. If you set this to 0 (zero), then resize in that direction will be disabled.

new Resizeable(‘foo’, {top: 0, left:50} );

A callback function can be defined that will be called when the resize is over.

new Resizeable(‘foo’, {resize: function(el) { alert(‘Done!’); } } );

The minimum height and width of the DIV can be specified as minHeight and minWidth options.

The resizable code in action – view source to see how it works.

The Javascript source file can be downloaded here

Currently, this code doesn’t quite work in IE (the DIV can jiggle around a little), but Firefox 1.0 is working Ok.

Weirdness in Napa

November 26, 2005 Link to post  Permalink

Last Saturday, we spent about 5 hours in Napa on a trip organized by the Seahawks. We visited two wineries – Opus One and Neibaum Coppola. We had a great time at both. Opus One took us on a tour of the facility and we had a tasting in a dining room that opens onto their impressive barrel room.

At Neibaum Coppola, they took us to a private area and we tasted wine and ate some great cheese.

Here’s where the weirdness begins. After our cheese and wine, a bunch of helicopters started buzzing around. It was quite annoying. It turns out that Christina Aguilera was getting married on a neighboring property.

The other weird thing. Whilst driving there and back, we noticed a house just off the road on a hill. It turns out it was the Napa house from this CNN article