39
<img alt="Phone_large" src="/system/photos/1/small/phone_large.jpg?1238845838" />

Why is "?1238845838" added to the image path?

How can I get my path/url without it?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Arwed
  • 1,755
  • 3
  • 16
  • 26

1 Answers1

77

It's commonly referred to as a "cache buster". Paperclip automatically appends the timestamp for the last time the file was updated.

Say you were to remove the cache buster and use /system/photos/1/small/phone_large.jpg instead. The URL wouldn't change when you changed the image and your visitors would see the old image for as long as they had it cached.

If you want to remove it just call .url(:default, timestamp: false). Of course you can change :default to any other style you've defined.

Or if you want to globally default them to off, just put this in a config/initializers/paperclip.rb file.

Paperclip::Attachment.default_options[:use_timestamp] = false
aNoble
  • 7,033
  • 2
  • 37
  • 33
  • 7
    If you are using image_tag helper timestamp will be added anyway, by Rails. – Art Shayderov Oct 03 '10 at 20:45
  • 5
    I had problems with `.url(:default, false)`, it was `.url(:original, timestamp: false)` that did the biz for me. – kim3er Mar 05 '13 at 12:30
  • How do you remove the cache_buster or where do you put the .url(:original, timestamp: false), in the model? – Ryan Jun 11 '13 at 21:39
  • 2
    @rncrtr, you'll want to either default the timestamps to be off by default, as I've added to my answer above. Or from your views you can do `` – aNoble Jun 12 '13 at 16:13