Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a rails app that dynamically generates thumbnails on request and saves the result locally to make it faster to serve up the same one again. We use the following url structure:


Where 99999 is the database record the thumb is linked to. The problem is the number of records with thumbnails is maxing out the directory limit.

Any ideas on how to get around this while maintaining the built in automatic cache retrieval that rails gives you with the public folder?

The end goal is to be able to dynamically generate arbitrary thumbnails on demand and cache the result locally.

share|improve this question

Use subdirectories, like:


and so on. Create as many subdirectories as you think are necessary for the unique identifier of your image, e.g.,:


You may need to be aware of the inode limits on your filesystem.

share|improve this answer
and how do I then tell nginx to map /thumbnails/99999/large.jpg to /thumbnails/099/999/large.jpg ? Or would you suggest we change it on the web request side too? More tedious than I was hoping, but I guess doable. – chrishomer Aug 13 '12 at 18:11
Well, certainly changing the request so that it hits the physical file would be best, as it removes a complication. It's possible to do a redirect through some regex, but that will be a lot more trouble than it's worth. – cjc Aug 13 '12 at 18:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.