How can I clear rails action cache? (Rails.cache.clear isn't working)
How can I clear rails action cache without restarting the server?
I have a script that updates the Postgres database with new data. I'd like to clear all cached pages after the script completes. but I can't seem to get this to take effect without completely restarting the Heroku server
I have tried without success:
Rails.cache.clear
=> ["/app/tmp/cache/bootsnap-compile-cache", "/app/tmp/cache/bootsnap-load-path-cache"]rails tmp:cache:clearrails assets:clean
config.cache_store is not set explicitly for production, (I've seen mixed information as to what cache is being used by default)
I have ensured that there is no caching in the browser (by disabling caching in dev tools and bypassing the service worker)
I'm using Heroku with ruby 2.5.3, rails 5.2.1.1, and actionpack-action_caching 1.2.0
How do I know it's not being cached at the database layer or with Fragment Caching?
I added logging to the action which only logs the first time a page is accessed after a restart
Update: I added some more logging and found out that my before actions are also being cached. They were working a few weeks ago.
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# add usable dom manipolation
gem 'jquery-rails'
# connect to the google spreadsheet to update the database
gem 'google_drive', '~> 3.0'
# maybe this will beeter support ios?
gem 'autoprefixer-rails', '~> 7.1', '>= 7.1.6'
# store site wide settings in the database
gem "rails-settings-cached"
# cache pages but still run before actions
gem 'actionpack-action_caching'
# servise worker helpers
gem "serviceworker-rails"
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ruby-on-rails ruby caching heroku
add a comment |
How can I clear rails action cache without restarting the server?
I have a script that updates the Postgres database with new data. I'd like to clear all cached pages after the script completes. but I can't seem to get this to take effect without completely restarting the Heroku server
I have tried without success:
Rails.cache.clear
=> ["/app/tmp/cache/bootsnap-compile-cache", "/app/tmp/cache/bootsnap-load-path-cache"]rails tmp:cache:clearrails assets:clean
config.cache_store is not set explicitly for production, (I've seen mixed information as to what cache is being used by default)
I have ensured that there is no caching in the browser (by disabling caching in dev tools and bypassing the service worker)
I'm using Heroku with ruby 2.5.3, rails 5.2.1.1, and actionpack-action_caching 1.2.0
How do I know it's not being cached at the database layer or with Fragment Caching?
I added logging to the action which only logs the first time a page is accessed after a restart
Update: I added some more logging and found out that my before actions are also being cached. They were working a few weeks ago.
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# add usable dom manipolation
gem 'jquery-rails'
# connect to the google spreadsheet to update the database
gem 'google_drive', '~> 3.0'
# maybe this will beeter support ios?
gem 'autoprefixer-rails', '~> 7.1', '>= 7.1.6'
# store site wide settings in the database
gem "rails-settings-cached"
# cache pages but still run before actions
gem 'actionpack-action_caching'
# servise worker helpers
gem "serviceworker-rails"
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ruby-on-rails ruby caching heroku
I wonder if this is an XY problem. Can you explain more about how you came to be certain that you need to clear the cache?
– anothermh
Dec 30 '18 at 7:26
I have a 400 line update script (with more than 20 methods), it destroys 5 database tables and imports fresh data into these tables. After I added action caching, I realized that the script doesn't take effect until the server is restarted.
– Arye Eidelman
Dec 30 '18 at 7:56
1
@AryeEidelman There are 3 possibilities; First one is, you are using in memory cache. In this case, even though you callRails.cache.clearit shouldn't clear the cache because your script and Rails application runs in different processes and each process has it's own heap. Second one is, you are using file store as cache store. In this case, you should make sure your script is in the same machine with your Rails application, otherwise it only removes local cache files. Third one is, you are using different cache stores for your Rails application and your cleanup script.
– Foo Bar Zoo
Dec 30 '18 at 10:55
@foo-bar-zoo thanks for the insight. As hazhir-derakhshi and others told me this should be using memory cache. So I'll add a clear cache button to the admin dashboard, that'll run Rails.cache.clear on the same process as the server. And see if that works.
– Arye Eidelman
Dec 30 '18 at 16:48
add a comment |
How can I clear rails action cache without restarting the server?
I have a script that updates the Postgres database with new data. I'd like to clear all cached pages after the script completes. but I can't seem to get this to take effect without completely restarting the Heroku server
I have tried without success:
Rails.cache.clear
=> ["/app/tmp/cache/bootsnap-compile-cache", "/app/tmp/cache/bootsnap-load-path-cache"]rails tmp:cache:clearrails assets:clean
config.cache_store is not set explicitly for production, (I've seen mixed information as to what cache is being used by default)
I have ensured that there is no caching in the browser (by disabling caching in dev tools and bypassing the service worker)
I'm using Heroku with ruby 2.5.3, rails 5.2.1.1, and actionpack-action_caching 1.2.0
How do I know it's not being cached at the database layer or with Fragment Caching?
I added logging to the action which only logs the first time a page is accessed after a restart
Update: I added some more logging and found out that my before actions are also being cached. They were working a few weeks ago.
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# add usable dom manipolation
gem 'jquery-rails'
# connect to the google spreadsheet to update the database
gem 'google_drive', '~> 3.0'
# maybe this will beeter support ios?
gem 'autoprefixer-rails', '~> 7.1', '>= 7.1.6'
# store site wide settings in the database
gem "rails-settings-cached"
# cache pages but still run before actions
gem 'actionpack-action_caching'
# servise worker helpers
gem "serviceworker-rails"
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ruby-on-rails ruby caching heroku
How can I clear rails action cache without restarting the server?
I have a script that updates the Postgres database with new data. I'd like to clear all cached pages after the script completes. but I can't seem to get this to take effect without completely restarting the Heroku server
I have tried without success:
Rails.cache.clear
=> ["/app/tmp/cache/bootsnap-compile-cache", "/app/tmp/cache/bootsnap-load-path-cache"]rails tmp:cache:clearrails assets:clean
config.cache_store is not set explicitly for production, (I've seen mixed information as to what cache is being used by default)
I have ensured that there is no caching in the browser (by disabling caching in dev tools and bypassing the service worker)
I'm using Heroku with ruby 2.5.3, rails 5.2.1.1, and actionpack-action_caching 1.2.0
How do I know it's not being cached at the database layer or with Fragment Caching?
I added logging to the action which only logs the first time a page is accessed after a restart
Update: I added some more logging and found out that my before actions are also being cached. They were working a few weeks ago.
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# add usable dom manipolation
gem 'jquery-rails'
# connect to the google spreadsheet to update the database
gem 'google_drive', '~> 3.0'
# maybe this will beeter support ios?
gem 'autoprefixer-rails', '~> 7.1', '>= 7.1.6'
# store site wide settings in the database
gem "rails-settings-cached"
# cache pages but still run before actions
gem 'actionpack-action_caching'
# servise worker helpers
gem "serviceworker-rails"
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
ruby-on-rails ruby caching heroku
ruby-on-rails ruby caching heroku
edited Dec 30 '18 at 7:41
Arye Eidelman
asked Dec 30 '18 at 4:31
Arye EidelmanArye Eidelman
191110
191110
I wonder if this is an XY problem. Can you explain more about how you came to be certain that you need to clear the cache?
– anothermh
Dec 30 '18 at 7:26
I have a 400 line update script (with more than 20 methods), it destroys 5 database tables and imports fresh data into these tables. After I added action caching, I realized that the script doesn't take effect until the server is restarted.
– Arye Eidelman
Dec 30 '18 at 7:56
1
@AryeEidelman There are 3 possibilities; First one is, you are using in memory cache. In this case, even though you callRails.cache.clearit shouldn't clear the cache because your script and Rails application runs in different processes and each process has it's own heap. Second one is, you are using file store as cache store. In this case, you should make sure your script is in the same machine with your Rails application, otherwise it only removes local cache files. Third one is, you are using different cache stores for your Rails application and your cleanup script.
– Foo Bar Zoo
Dec 30 '18 at 10:55
@foo-bar-zoo thanks for the insight. As hazhir-derakhshi and others told me this should be using memory cache. So I'll add a clear cache button to the admin dashboard, that'll run Rails.cache.clear on the same process as the server. And see if that works.
– Arye Eidelman
Dec 30 '18 at 16:48
add a comment |
I wonder if this is an XY problem. Can you explain more about how you came to be certain that you need to clear the cache?
– anothermh
Dec 30 '18 at 7:26
I have a 400 line update script (with more than 20 methods), it destroys 5 database tables and imports fresh data into these tables. After I added action caching, I realized that the script doesn't take effect until the server is restarted.
– Arye Eidelman
Dec 30 '18 at 7:56
1
@AryeEidelman There are 3 possibilities; First one is, you are using in memory cache. In this case, even though you callRails.cache.clearit shouldn't clear the cache because your script and Rails application runs in different processes and each process has it's own heap. Second one is, you are using file store as cache store. In this case, you should make sure your script is in the same machine with your Rails application, otherwise it only removes local cache files. Third one is, you are using different cache stores for your Rails application and your cleanup script.
– Foo Bar Zoo
Dec 30 '18 at 10:55
@foo-bar-zoo thanks for the insight. As hazhir-derakhshi and others told me this should be using memory cache. So I'll add a clear cache button to the admin dashboard, that'll run Rails.cache.clear on the same process as the server. And see if that works.
– Arye Eidelman
Dec 30 '18 at 16:48
I wonder if this is an XY problem. Can you explain more about how you came to be certain that you need to clear the cache?
– anothermh
Dec 30 '18 at 7:26
I wonder if this is an XY problem. Can you explain more about how you came to be certain that you need to clear the cache?
– anothermh
Dec 30 '18 at 7:26
I have a 400 line update script (with more than 20 methods), it destroys 5 database tables and imports fresh data into these tables. After I added action caching, I realized that the script doesn't take effect until the server is restarted.
– Arye Eidelman
Dec 30 '18 at 7:56
I have a 400 line update script (with more than 20 methods), it destroys 5 database tables and imports fresh data into these tables. After I added action caching, I realized that the script doesn't take effect until the server is restarted.
– Arye Eidelman
Dec 30 '18 at 7:56
1
1
@AryeEidelman There are 3 possibilities; First one is, you are using in memory cache. In this case, even though you call
Rails.cache.clear it shouldn't clear the cache because your script and Rails application runs in different processes and each process has it's own heap. Second one is, you are using file store as cache store. In this case, you should make sure your script is in the same machine with your Rails application, otherwise it only removes local cache files. Third one is, you are using different cache stores for your Rails application and your cleanup script.– Foo Bar Zoo
Dec 30 '18 at 10:55
@AryeEidelman There are 3 possibilities; First one is, you are using in memory cache. In this case, even though you call
Rails.cache.clear it shouldn't clear the cache because your script and Rails application runs in different processes and each process has it's own heap. Second one is, you are using file store as cache store. In this case, you should make sure your script is in the same machine with your Rails application, otherwise it only removes local cache files. Third one is, you are using different cache stores for your Rails application and your cleanup script.– Foo Bar Zoo
Dec 30 '18 at 10:55
@foo-bar-zoo thanks for the insight. As hazhir-derakhshi and others told me this should be using memory cache. So I'll add a clear cache button to the admin dashboard, that'll run Rails.cache.clear on the same process as the server. And see if that works.
– Arye Eidelman
Dec 30 '18 at 16:48
@foo-bar-zoo thanks for the insight. As hazhir-derakhshi and others told me this should be using memory cache. So I'll add a clear cache button to the admin dashboard, that'll run Rails.cache.clear on the same process as the server. And see if that works.
– Arye Eidelman
Dec 30 '18 at 16:48
add a comment |
1 Answer
1
active
oldest
votes
As you can see here, default cache store in production is mem_cache_store. Therefore, you should be able to clear it in different ways, without restarting the sever. Maciej Mensfeld wrote a blog about these ways. I personally use flush_all command in the cache server if Rails.cache.clear does not make effect.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975298%2fhow-can-i-clear-rails-action-cache-rails-cache-clear-isnt-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As you can see here, default cache store in production is mem_cache_store. Therefore, you should be able to clear it in different ways, without restarting the sever. Maciej Mensfeld wrote a blog about these ways. I personally use flush_all command in the cache server if Rails.cache.clear does not make effect.
add a comment |
As you can see here, default cache store in production is mem_cache_store. Therefore, you should be able to clear it in different ways, without restarting the sever. Maciej Mensfeld wrote a blog about these ways. I personally use flush_all command in the cache server if Rails.cache.clear does not make effect.
add a comment |
As you can see here, default cache store in production is mem_cache_store. Therefore, you should be able to clear it in different ways, without restarting the sever. Maciej Mensfeld wrote a blog about these ways. I personally use flush_all command in the cache server if Rails.cache.clear does not make effect.
As you can see here, default cache store in production is mem_cache_store. Therefore, you should be able to clear it in different ways, without restarting the sever. Maciej Mensfeld wrote a blog about these ways. I personally use flush_all command in the cache server if Rails.cache.clear does not make effect.
answered Dec 30 '18 at 8:00
Hazhir DerakhshiHazhir Derakhshi
213
213
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975298%2fhow-can-i-clear-rails-action-cache-rails-cache-clear-isnt-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I wonder if this is an XY problem. Can you explain more about how you came to be certain that you need to clear the cache?
– anothermh
Dec 30 '18 at 7:26
I have a 400 line update script (with more than 20 methods), it destroys 5 database tables and imports fresh data into these tables. After I added action caching, I realized that the script doesn't take effect until the server is restarted.
– Arye Eidelman
Dec 30 '18 at 7:56
1
@AryeEidelman There are 3 possibilities; First one is, you are using in memory cache. In this case, even though you call
Rails.cache.clearit shouldn't clear the cache because your script and Rails application runs in different processes and each process has it's own heap. Second one is, you are using file store as cache store. In this case, you should make sure your script is in the same machine with your Rails application, otherwise it only removes local cache files. Third one is, you are using different cache stores for your Rails application and your cleanup script.– Foo Bar Zoo
Dec 30 '18 at 10:55
@foo-bar-zoo thanks for the insight. As hazhir-derakhshi and others told me this should be using memory cache. So I'll add a clear cache button to the admin dashboard, that'll run Rails.cache.clear on the same process as the server. And see if that works.
– Arye Eidelman
Dec 30 '18 at 16:48