I am trying to use locMemCache to cache some views with Django. When I cache the whole site with the following settings for middleware, everything works as expected, I have both html minification and caching working properly:
MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddleware',
'htmlmin.middleware.HtmlMinifyMiddleware',
[...]
'django.middleware.cache.FetchFromCacheMiddleware',
'htmlmin.middleware.MarkRequestMiddleware',
]
However, when I try to cache only some specific views, I delete both UpdateCacheMiddleware and FetchFromCacheMiddleware, and use instead the following in urls.py (as per django documentation about cache framework):
from django.views.decorators.cache import cache_page
urlpatterns = [
path('', cache_page(600)(views.HomePage.as_view()), name='home'),
]
Then, if I do not use htmlmin (HTML_MINIFY = False), caching is working fine. But if I activate htmlmin, caching is not working anymore. I tried to move htmlmin.middleware.HtmlMinifyMiddleware and htmlmin.middleware.MarkRequestMiddleware at different locations in the MIDDLEWARE setting, beginning, end, but without any effect. I also tried to use only one of the two htmlmin middlewares, but then there is no minification.
What am I missing here? Is it possible to use htmlmin with per-view caching?
I am trying to use locMemCache to cache some views with Django. When I cache the whole site with the following settings for middleware, everything works as expected, I have both html minification and caching working properly:
However, when I try to cache only some specific views, I delete both UpdateCacheMiddleware and FetchFromCacheMiddleware, and use instead the following in urls.py (as per django documentation about cache framework):
Then, if I do not use htmlmin (HTML_MINIFY = False), caching is working fine. But if I activate htmlmin, caching is not working anymore. I tried to move htmlmin.middleware.HtmlMinifyMiddleware and htmlmin.middleware.MarkRequestMiddleware at different locations in the MIDDLEWARE setting, beginning, end, but without any effect. I also tried to use only one of the two htmlmin middlewares, but then there is no minification.
What am I missing here? Is it possible to use htmlmin with per-view caching?