Skip to content

Commit

Permalink
Added a timestamp to the captcha url. Added a set_cache buster method
Browse files Browse the repository at this point in the history
to application controller to prevent the browser from caching pages.
  • Loading branch information
Doug Youch committed Aug 12, 2010
1 parent 208a825 commit c756d63
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -159,6 +159,13 @@ def check_ssl #:nodoc:
end
end

# Helper method to tell the browser not to cache a page
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end

# helper method to redirect a user to the access denied page
# call from a controller method with :
#
Expand Down
Expand Up @@ -2,6 +2,7 @@
class Feedback::CaptchaController < ApplicationController
def image
@captcha = WebivaCaptcha.new self
set_cache_buster
render :text => @captcha.render
end
end
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules/feedback/app/models/feedback_captcha.rb
Expand Up @@ -52,7 +52,7 @@ def phrase
end

def url
"/website/feedback/captcha/image/#{self.captcha_code}"
"/website/feedback/captcha/image/#{self.captcha_code}?Z=#{Time.now.to_i}"
end

def partial
Expand Down

0 comments on commit c756d63

Please sign in to comment.