Skip to content

Commit b7d781b

Browse files
ugisozolsparndt
authored andcommitted
Remove invalidate_cached_urls.
It's not needed because: * cache is cleared by after_filter in admin pages controller * when rebuild is called it runs #invalidate_cached_urls on every page and its children so in case user has many pages it causes a lot of queries which increases load time and sometimes even time out. See #1954 for discussion.
1 parent 684a175 commit b7d781b

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

Diff for: pages/app/models/refinery/page.rb

+1-19
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ class Translation
5858
before_save { |m| m.translation.save }
5959
before_create :ensure_locale, :if => proc { ::Refinery.i18n_enabled? }
6060
before_destroy :deletable?
61-
after_save :reposition_parts!, :invalidate_cached_urls, :expire_page_caching
62-
after_update :invalidate_cached_urls
61+
after_save :reposition_parts!, :expire_page_caching
6362
after_destroy :expire_page_caching
6463

6564
class << self
@@ -187,12 +186,6 @@ def expire_page_caching
187186
return true # so that other callbacks process.
188187
end
189188
end
190-
191-
def rebuild_with_invalidate_cached_urls!
192-
rebuild_without_invalidate_cached_urls!
193-
find_each { |page| page.send :invalidate_cached_urls }
194-
end
195-
alias_method_chain :rebuild!, :invalidate_cached_urls
196189
end
197190

198191
# The canonical page for this particular page.
@@ -441,17 +434,6 @@ def normalize_friendly_id_with_marketable_urls(slug_string)
441434
alias_method_chain :normalize_friendly_id, :marketable_urls
442435

443436
private
444-
def invalidate_cached_urls
445-
return true unless Refinery::Pages.marketable_urls
446-
447-
[self, children].flatten.each do |page|
448-
((Refinery.i18n_enabled? && Refinery::I18n.frontend_locales) || [::I18n.locale]).each do |locale|
449-
Rails.cache.delete(page.url_cache_key(locale))
450-
Rails.cache.delete(page.path_cache_key(locale))
451-
end
452-
end
453-
end
454-
alias_method :invalidate_child_cached_url, :invalidate_cached_urls
455437

456438
# Make sures that a translation exists for this page.
457439
# The translation is set to the default frontend locale.

0 commit comments

Comments
 (0)