I’m using paperclip in my Rails 3.2 app to manage image attachments and to show model-associated images in my views. It works great, but I’ve never completely grasped what’s going on with the 10-digit number (fingerprint? checksum? hash?) that paperclip adds to the image filenames.
For example, when I view my page using Chrome’s developer tools, I see something like this:
<img src="/acquisitionist/system/logos/27/thumb/foo_logo.jpg?1386362710">
My first question is, what’s the 10-digit number at the end called? Is this the MD5 checksum/fingerprint mentioned in the Paperclip docs at Github? Does something similar happen to images served by the asset pipeline?
Updated: I found an answer on StackOverflow that called this a “cache buster”, which makes sense. I also discovered that the 10-digit number is basically the attachment_updated_at.to_i timestamp for the model the attachment is associated with.
My second question arises out of the following situation. I’ve created a backup copy of my production application on a different (backup) server. To set up my app on the backup server, I’ve cloned the app’s github repository and created the mysql database from a backup dump. I’ve also copied over the paperclip attachments from the public/system folder of the main app to the analogous subdirectory on the backup server.
The app runs on the backup server, but the images uploaded via paperclip attachments show up as broken. This appears to be related to the 10-digit number at the end of the filename.
Updated: looking in the console for Chrome’s developer tools, I see that when I try to view these images on the backup server version of my application, the images return 403 (Forbidden) errors. Is viewing these images forbidden due to some sort of mismatch between the attachment_updated_at field for the model in the backed-up database and the original one? If not, what is the reason for the 403 and how can I best deal with it?
Is there a way for me to regenerate new versions of the 10-digit number for the paperclip images on my backup server? Or is there a paperclip rake task that deals with this issue? Or do I need to set some settings in an initializer file or in other rails config files to deal with this issue?
Updated: I found a StackOverflow answer that discussed setting the :timestamp => false option within the paperclip URL in my views. Is this the right way do deal with the 403 error?
Thanks very much,
Dean Richardson