New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dev caching toggle / server options #20961
Conversation
end | ||
|
||
def test_caching_with_option | ||
args = ["-C"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could potentially cause some confusion, as there is already a -c
option. I think it should be changed, I just didn't have a notion of what it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be easier to grasp as just --toggle-caching
- maybe we don't even need a shorthand?
Though I'm still ¯_(ツ)_/¯ about the server options in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaspth I'm ambivalent about the whole thing as well, just added it as it seemed there was support in the previous PR. I'll go with the hivemind on it.
If you change your pull request description to say "Fixes #18875" the original issue will be closed if this is merged 😄 |
@kaspth Thank you for the suggestions -- I'll implement them this evening! |
@@ -67,6 +69,7 @@ def start | |||
print_boot_information | |||
trap(:INT) { exit } | |||
create_tmp_directories | |||
create_cache_file if options[:cache] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like setting --perform-caching
once never removes the file and leaves caching on all the time. Let's fix that 😄
@kaspth I implemented most of your suggestions. Instead of having a |
Awesome. Thanks for working on this! |
@@ -1,3 +1,11 @@ | |||
* Make enabling or disabling caching in development mode possible with rake dev:cache | |||
|
|||
Running rake dev:cache will create or remove tmp/caching-dev.txt. When this file exists config.action_controller.perform_caching will be set to true in config/environments/development.rb. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break the lines at 80 chars 😄
Alright, once the final comment has been addressed, ping me. Remember to keep it to one commit, then I'll gladly merge 😁 |
I just realized there's a scenario we have to make sure doesn't happen. Maybe I'm misunderstanding something, but what happens when There's no I'd like a test that checks against this. |
@kaspth That's a good point! I'll write the test and if it fails find a workaround. |
@kaspth The easiest way to fix the above is just by defaulting the server to create the cache file if options are passed. Otherwise, default to the last Additionally, I couldn't find any concrete examples of tests that check the server start. Could you point me toward some (if they exist)? |
Honestly, that Looking back to @pixeltrix's original suggestion I see Perhaps |
@ccallebs Sorry, I'm not aware of any tests checking the server start. |
@ccallebs are you up for adding an argument to |
@kaspth Absolutely! Sorry, I've been busy and haven't been able to sit down and do it. I'll try to tackle it this evening. |
Cool, glad to hear it 😄 |
Taken from @Sonopa's commits on PR #19091. Add support for dev caching via "rails s" flags. Implement suggestions from @kaspth. Remove temporary cache file if server does not have flags. Break at 80 characters in railties/CHANGELOG.md Remove ability to disable cache based on server options. Add more comprehensive options: --dev-caching / --no-dev-caching
@kaspth After looking at the OptionParser documentation, I ended up changing the name of the keyword. (http://docs.ruby-lang.org/en/2.2.0/OptionParser.html) Now, it would be |
Add dev caching toggle / server options
@ccallebs Thanks ❤️ |
On a new Rails app, [`config/development.rb`](https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt#L19) is set up to support [`rails dev:cache`](rails#20961). This PR explains how to enable caching in development in https://guides.rubyonrails.org/caching_with_rails.html, replacing the old advice that looks like it came before rails#20961.
Apologies for resurrecting an ancient PR thread but... wouldn't it make more sense to have the task called |
Taken extensively from @Sonopa's PR (#19091). Added ability to specify caching on server start.
Fixes #18875.