Search code examples
rubyrackspace-cloud

how do I set Cache-Control header for Cloud Files with Fog


I've tried various combinations of the following, but none worked

file = dir.files.create(
                        :key    => file_name,
                        :body   => io_obj,
                        :public => true,
                        'Cache-Control' => "max-age=#{(60 * 60 * 24 * 30 * 6).to_s}"
                                )

Solution

  • Whilst I haven't tested this explicitly on Rackspace Cloud, this is what I have been using (successfully) for my S3 uploads with Fog:

    file = dir.files.create({
      :key    => filename
      :body   => File.open(filename),
      :public => true,
      :metadata => {'Cache-Control' => 'max-age=315576000'}
    })