开发者

How do I stop my rails application from returning a 304

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开发者_C百科 to prevent my rails application from doing this?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜