Add two new setting options to control the caching of page images.
DOCUMENTS_DISABLE_BASE_IMAGE_CACHE and DOCUMENTS_DISABLE_TRANSFORMED_IMAGE_CACHE. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -65,6 +65,18 @@ Other Changes
|
||||
- Add "Remember me" checkbox in the login form.
|
||||
- Add AUTHENTICATION_MAXIMUM_SESSION_LENGTH configuration setting for the maximum
|
||||
time an user's login session will remain valid. Defaults to 30 days.
|
||||
- Ability to disable the document page image caching. This feature is controlled
|
||||
by two new settings: DOCUMENTS_DISABLE_TRANSFORMED_IMAGE_CACHE and
|
||||
DOCUMENTS_DISABLE_BASE_IMAGE_CACHE. DOCUMENTS_DISABLE_BASE_IMAGE_CACHE
|
||||
disables the first layer of caching, the generation of a master image file
|
||||
for each document page. This means that subsequent request for a page's
|
||||
image will trigger the conversion of the document from its original
|
||||
uploaded file. The second option, DOCUMENTS_DISABLE_TRANSFORMED_IMAGE_CACHE,
|
||||
disables just the caching of the transformed (rotated, resized, zoomed)
|
||||
images of document pages. The settings can be used together or separately
|
||||
depending on how much disk space saving is desired. These settings give control
|
||||
over the trade-off between disk space savings and higher CPU utilization.
|
||||
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -36,6 +36,7 @@ from .managers import (
|
||||
from .permissions import permission_document_view
|
||||
from .runtime import cache_storage_backend, storage_backend
|
||||
from .settings import (
|
||||
setting_disable_base_image_cache, setting_disable_transformed_image_cache,
|
||||
setting_display_size, setting_language, setting_zoom_max_level,
|
||||
setting_zoom_min_level
|
||||
)
|
||||
@@ -768,11 +769,14 @@ class DocumentPage(models.Model):
|
||||
# Check is transformed image is available
|
||||
logger.debug('transformations cache filename: %s', cache_filename)
|
||||
|
||||
if cache_storage_backend.exists(cache_filename):
|
||||
if not setting_disable_transformed_image_cache.value and cache_storage_backend.exists(cache_filename):
|
||||
logger.debug(
|
||||
'transformations cache file "%s" found', cache_filename
|
||||
)
|
||||
else:
|
||||
logger.debug(
|
||||
'transformations cache file "%s" not found', cache_filename
|
||||
)
|
||||
image = self.get_image(transformations=transformation_list)
|
||||
with cache_storage_backend.open(cache_filename, 'wb+') as file_object:
|
||||
file_object.write(image.getvalue())
|
||||
@@ -785,7 +789,7 @@ class DocumentPage(models.Model):
|
||||
cache_filename = self.cache_filename
|
||||
logger.debug('Page cache filename: %s', cache_filename)
|
||||
|
||||
if cache_storage_backend.exists(cache_filename):
|
||||
if not setting_disable_base_image_cache.value and cache_storage_backend.exists(cache_filename):
|
||||
logger.debug('Page cache file "%s" found', cache_filename)
|
||||
converter = converter_class(
|
||||
file_object=cache_storage_backend.open(cache_filename)
|
||||
|
||||
@@ -73,3 +73,18 @@ setting_language_choices = namespace.add_setting(
|
||||
global_name='DOCUMENTS_LANGUAGE_CHOICES', default=LANGUAGE_CHOICES,
|
||||
help_text=_('List of supported document languages.')
|
||||
)
|
||||
setting_disable_base_image_cache = namespace.add_setting(
|
||||
global_name='DOCUMENTS_DISABLE_BASE_IMAGE_CACHE', default=False,
|
||||
help_text=_(
|
||||
'Disables the first cache tier which stores high resolution, '
|
||||
'non transformed versions of documents\'s pages.'
|
||||
)
|
||||
)
|
||||
setting_disable_transformed_image_cache = namespace.add_setting(
|
||||
global_name='DOCUMENTS_DISABLE_TRANSFORMED_IMAGE_CACHE', default=False,
|
||||
help_text=_(
|
||||
'Disables the second cache tier which stores medium to low '
|
||||
'resolution, transformed (rotated, zoomed, etc) versions '
|
||||
'of documents\' pages.'
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user