django-pipeline icon indicating copy to clipboard operation
django-pipeline copied to clipboard

Use ManifestStaticFilesStorage instead of CachedStaticFilesStorage

Open bitcity opened this issue 7 years ago • 1 comments

Question : Would ManifestStaticFilesStorage be a suitable replacement when using cache busting url for this project ?

Reason : According to recent Django docs

Warning CachedStaticFilesStorage isn’t recommended – in almost all cases ManifestStaticFilesStorage is a better choice. There are several performance penalties when using CachedStaticFilesStorage since a cache miss requires hashing files at runtime. Remote file storage require several round-trips to hash a file on a cache miss, as several file accesses are required to ensure that the file hash is correct in the case of nested file paths.

Another good article : https://devblog.kogan.com/blog/a-hidden-gem-in-django-1-7-manifeststaticfilesstorage

bitcity avatar Apr 19 '17 13:04 bitcity

RemovedInDjango31Warning: CachedStaticFilesStorage is deprecated in favor of ManifestStaticFilesStorage.

brianmay avatar Jun 05 '19 07:06 brianmay

Hi souls!

I just came across this issue while investigating something slightly related.

@bitcity I would say the project already uses ManifestStaticFilesStorage when possible:

(from pipeline.storage)

from django.contrib.staticfiles.storage import (
    ManifestStaticFilesStorage,
    StaticFilesStorage,
)
from django.contrib.staticfiles.utils import matches_patterns
from django.core.files.base import File

_CACHED_STATIC_FILES_STORAGE_AVAILABLE = django_version() < "3.1"

if _CACHED_STATIC_FILES_STORAGE_AVAILABLE:
    from django.contrib.staticfiles.storage import CachedStaticFilesStorage

So...I guess your questioned is already answered and the issue solved?

m0nt3cr1st0 avatar Oct 02 '24 14:10 m0nt3cr1st0

Assuming this can be closed...

brianmay avatar Oct 02 '24 21:10 brianmay