Skip to content

Commit

Permalink
Proper caching of descriptions pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ujh committed Jan 6, 2025
1 parent 6aabc70 commit 1bc99d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/views/descriptions/missing.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ div class='fpc-hint alert alert-secondary'
= link_to "here", my_missing_descriptions_path
' .

- cache(['missing_brands', params[:brands_page]], expires_in: 6.hours ) do
- cache(['missing_brands', params[:brands_page], params[:inks_page]], expires_in: 6.hours ) do
= render 'missing_brands_table', { missing_brands: @missing_brands }

div class='fpc-hint alert alert-secondary'
Expand All @@ -23,5 +23,5 @@ div class='fpc-hint alert alert-secondary'
= link_to "here", my_missing_descriptions_path
' .

- cache(['missing_inks', params[:inks_page]], expires_in: 6.hours ) do
- cache(['missing_inks', params[:brands_page], params[:inks_page]], expires_in: 6.hours ) do
= render 'missing_inks_table', { missing_inks: @missing_inks }
4 changes: 4 additions & 0 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
end
end

Rack::Attack.throttle("missing descriptions", limit: 1, period: 1) do |request|
request.ip if request.path.starts_with?("/descriptions/missing")
end

# See https://social.treehouse.systems/@dee/112524729369220652
Rack::Attack.blocklist("Misbehaving bots") do |request|
request.user_agent =~
Expand Down

0 comments on commit 1bc99d4

Please sign in to comment.