Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to easily disable disk-cache #7928

Merged
merged 4 commits into from Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion docs/_docs/configuration/options.md
Expand Up @@ -43,13 +43,35 @@ class="flag">flags</code> (specified on the command-line) that control them.
<tr class="setting">
<td>
<p class="name"><strong>Safe</strong></p>
<p class="description">Disable <a href="/docs/plugins/">custom plugins, and ignore symbolic links</a>.</p>
<p class="description">
Disable <a href="/docs/plugins/">custom plugins</a>, caching to disk
and ignore symbolic links.
</p>
</td>
<td class="align-center">
<p><code class="option">safe: BOOL</code></p>
<p><code class="flag">--safe</code></p>
</td>
</tr>
<tr class="setting">
<td>
<p class="name">
<strong>Disable Disk Cache</strong>
<span class="version-badge" title="Introduced in v4.1.0">4.1.0</span>
</p>
<p class="description">
Disable caching of content to disk in order to skip creating a
<code>.jekyll-cache</code> or similar directory at the source
to avoid interference with virtual environments and third-party
directory watchers.
Caching to disk is always disabled in <code>safe</code> mode.
</p>
</td>
<td class="align-center">
<p><code class="option">disable_disk_cache: BOOL</code></p>
<p><code class="flag">--disable-disk-cache</code></p>
</td>
</tr>
<tr class="setting">
<td>
<p class="name"><strong>Exclude</strong></p>
Expand Down
9 changes: 9 additions & 0 deletions features/cache.feature
Expand Up @@ -35,3 +35,12 @@ Feature: Cache
But the .jekyll-cache directory should not exist
And the _site directory should exist
And I should see "<p>Hello World</p>" in "_site/index.html"

Scenario: Disabling disk usage in non-safe mode
Given I have an "index.md" page that contains "{{ site.title }}"
And I have a configuration file with "title" set to "Hello World"
When I run jekyll build --disable-disk-cache
Then I should get a zero exit status
And the _site directory should exist
And I should see "<p>Hello World</p>" in "_site/index.html"
But the .jekyll-cache directory should not exist
2 changes: 2 additions & 0 deletions lib/jekyll/command.rb
Expand Up @@ -67,6 +67,8 @@ def add_build_options(cmd)
cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
cmd.option "unpublished", "--unpublished",
"Render posts that were marked as unpublished"
cmd.option "disable_disk_cache", "--disable-disk-cache",
"Disable caching to disk in non-safe mode"
cmd.option "quiet", "-q", "--quiet", "Silence output."
cmd.option "verbose", "-V", "--verbose", "Print verbose output."
cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/site.rb
Expand Up @@ -470,7 +470,7 @@ def site_cleaner
# Disable Marshaling cache to disk in Safe Mode
def configure_cache
Jekyll::Cache.cache_dir = in_source_dir(config["cache_dir"], "Jekyll/Cache")
Jekyll::Cache.disable_disk_cache! if safe
Jekyll::Cache.disable_disk_cache! if safe || config["disable_disk_cache"]
end

def configure_plugins
Expand Down