How do I stop my rails application from returning a 304
Asked Answered
I

1

16

I have a feeds controller that should NEVER return a 304.

My render call looks like this ( where json_feed_content is a jsonp string );

render :text => jsonp_feed_content, :content_type => "application/json"

I have set caching to false in my production environment:

config.action_controller.perform_caching = false

I have a client script that constantly polls content from this feed, but most of the requests return 304 [Content Not Changed]. Is there a way to prevent my rails application from doing this?

Idealistic answered 29/3, 2011 at 7:36 Comment(1)
is it doing a model/sql query? can you post a sample of the whole log?Kissable
S
26

Add this to your controller:

#update last-modified so content is always fresh
headers['Last-Modified'] = Time.now.httpdate

There might be better ways, but this worked for me.

Schizoid answered 2/4, 2011 at 13:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.