diff --git a/docs/settings.rst b/docs/settings.rst index 99829258..b4e73316 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -204,7 +204,7 @@ Setting name (followed by default value, if any) ``SLUGIFY_SOURCE = 'title'`` Specifies where you want the slug to be automatically generated from. Can be set to ``title`` to use the 'Title:' metadata tag or ``basename`` to use the article's file name when creating the slug. -``CACHE_CONTENT = True`` If ``True``, save content in a cache file. +``CACHE_CONTENT = False`` If ``True``, saves content in caches. See :ref:`reading_only_modified_content` for details about caching. ``CONTENT_CACHING_LAYER = 'reader'`` If set to ``'reader'``, save only the raw content and metadata returned by readers. If set to ``'generator'``, save processed @@ -212,9 +212,7 @@ Setting name (followed by default value, if any) ``CACHE_PATH = 'cache'`` Directory in which to store cache files. ``GZIP_CACHE = True`` If ``True``, use gzip to (de)compress the cache files. ``CHECK_MODIFIED_METHOD = 'mtime'`` Controls how files are checked for modifications. -``LOAD_CONTENT_CACHE = True`` If ``True``, load unmodified content from cache. -``AUTORELOAD_IGNORE_CACHE = False`` If ``True``, do not load content cache in autoreload mode - when the settings file changes. +``LOAD_CONTENT_CACHE = False`` If ``True``, load unmodified content from caches. ``WRITE_SELECTED = []`` If this list is not empty, **only** output files with their paths in this list are written. Paths should be either absolute or relative to the current Pelican working directory. For possible use cases see diff --git a/pelican/__init__.py b/pelican/__init__.py index 12da111a..98e783d7 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -101,6 +101,11 @@ class Pelican(object): 'PAGE_LANG_URL'): logger.warning("%s = '%s'", setting, self.settings[setting]) + if self.settings.get('AUTORELOAD_IGNORE_CACHE'): + logger.warning('Found deprecated `AUTORELOAD_IGNORE_CACHE` in ' + 'settings. Use --ignore-cache instead.') + self.settings.pop('AUTORELOAD_IGNORE_CACHE') + if self.settings.get('ARTICLE_PERMALINK_STRUCTURE', False): logger.warning('Found deprecated `ARTICLE_PERMALINK_STRUCTURE` in' ' settings. Modifying the following settings for' @@ -381,10 +386,6 @@ def main(): print(' --- AutoReload Mode: Monitoring `content`, `theme` and' ' `settings` for changes. ---') - def _ignore_cache(pelican_obj): - if pelican_obj.settings['AUTORELOAD_IGNORE_CACHE']: - pelican_obj.settings['LOAD_CONTENT_CACHE'] = False - while True: try: # Check source dir for changed files ending with the given @@ -393,12 +394,9 @@ def main(): # have changed, no matter what extension the filenames # have. modified = {k: next(v) for k, v in watchers.items()} - original_load_cache = settings['LOAD_CONTENT_CACHE'] if modified['settings']: pelican, settings = get_instance(args) - original_load_cache = settings['LOAD_CONTENT_CACHE'] - _ignore_cache(pelican) # Adjust static watchers if there are any changes new_static = settings.get("STATIC_PATHS", []) @@ -435,8 +433,6 @@ def main(): 'theme.') pelican.run() - # restore original caching policy - pelican.settings['LOAD_CONTENT_CACHE'] = original_load_cache except KeyboardInterrupt: logger.warning("Keyboard interrupt, quitting.") diff --git a/pelican/settings.py b/pelican/settings.py index 0c54e89b..82955277 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -123,13 +123,12 @@ DEFAULT_CONFIG = { 'SLUG_SUBSTITUTIONS': (), 'INTRASITE_LINK_REGEX': '[{|](?P.*?)[|}]', 'SLUGIFY_SOURCE': 'title', - 'CACHE_CONTENT': True, + 'CACHE_CONTENT': False, 'CONTENT_CACHING_LAYER': 'reader', 'CACHE_PATH': 'cache', 'GZIP_CACHE': True, 'CHECK_MODIFIED_METHOD': 'mtime', - 'LOAD_CONTENT_CACHE': True, - 'AUTORELOAD_IGNORE_CACHE': False, + 'LOAD_CONTENT_CACHE': False, 'WRITE_SELECTED': [], 'FORMATTED_FIELDS': ['summary'], } diff --git a/pelican/tests/test_cache.py b/pelican/tests/test_cache.py index 9b4150cc..8a20c36b 100644 --- a/pelican/tests/test_cache.py +++ b/pelican/tests/test_cache.py @@ -28,11 +28,18 @@ class TestCache(unittest.TestCase): def tearDown(self): rmtree(self.temp_cache) + def _get_cache_enabled_settings(self): + settings = get_settings(filenames={}) + settings['CACHE_CONTENT'] = True + settings['LOAD_CONTENT_CACHE'] = True + settings['CACHE_PATH'] = self.temp_cache + return settings + + @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_article_object_caching(self): """Test Article objects caching at the generator level""" - settings = get_settings(filenames={}) - settings['CACHE_PATH'] = self.temp_cache + settings = self._get_cache_enabled_settings() settings['CONTENT_CACHING_LAYER'] = 'generator' settings['DEFAULT_DATE'] = (1970, 1, 1) settings['READERS'] = {'asc': None} @@ -60,8 +67,7 @@ class TestCache(unittest.TestCase): @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_article_reader_content_caching(self): """Test raw article content caching at the reader level""" - settings = get_settings(filenames={}) - settings['CACHE_PATH'] = self.temp_cache + settings = self._get_cache_enabled_settings() settings['READERS'] = {'asc': None} generator = ArticlesGenerator( @@ -85,8 +91,7 @@ class TestCache(unittest.TestCase): """Test that all the articles are read again when not loading cache used in --ignore-cache or autoreload mode""" - settings = get_settings(filenames={}) - settings['CACHE_PATH'] = self.temp_cache + settings = self._get_cache_enabled_settings() settings['READERS'] = {'asc': None} generator = ArticlesGenerator( @@ -108,10 +113,9 @@ class TestCache(unittest.TestCase): @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_page_object_caching(self): """Test Page objects caching at the generator level""" - settings = get_settings(filenames={}) - settings['CACHE_PATH'] = self.temp_cache - settings['PAGE_PATHS'] = ['TestPages'] + settings = self._get_cache_enabled_settings() settings['CONTENT_CACHING_LAYER'] = 'generator' + settings['PAGE_PATHS'] = ['TestPages'] settings['READERS'] = {'asc': None} generator = PagesGenerator( @@ -134,8 +138,7 @@ class TestCache(unittest.TestCase): @unittest.skipUnless(MagicMock, 'Needs Mock module') def test_page_reader_content_caching(self): """Test raw page content caching at the reader level""" - settings = get_settings(filenames={}) - settings['CACHE_PATH'] = self.temp_cache + settings = self._get_cache_enabled_settings() settings['PAGE_PATHS'] = ['TestPages'] settings['READERS'] = {'asc': None} @@ -160,8 +163,7 @@ class TestCache(unittest.TestCase): """Test that all the pages are read again when not loading cache used in --ignore_cache or autoreload mode""" - settings = get_settings(filenames={}) - settings['CACHE_PATH'] = self.temp_cache + settings = self._get_cache_enabled_settings() settings['PAGE_PATHS'] = ['TestPages'] settings['READERS'] = {'asc': None}