Fixed bug in cache_page decorator#64
Conversation
It is necessary to introduce `HTTP_X_FLAVOUR` header before standard Django `CacheMiddleware` in request and patch `Vary:` headers before standard Django `CacheMiddleware` in response as well Thus, nesting flavour decorator inside cache decorator is not correct and we need two separate flavour decorators for caching with flavour
|
Hi, thanks for the proposal. Splitting the middleware into two only makes sense if they are applied in different ends of the MIDDLEWARE_CLASSES setting. Can you describe/document, what would need to be changed in existing installations? |
|
Oh, i just followed the django.cache logic. They also split the CacheMiddleware in two, though the later inherit CacheMiddleware from both. Here we actually split the @cache_page logic in two parts - because if we nest it like it was, HTTP_X_FLAVOUR header will be set after the standard CacheMiddleware makes the cache key. |
|
Ok, that makes sense to me :) do you think we would need to adjust the README in this context. It currently states:
|
|
Yep, i think we should but i'm currently afk |
|
Alright, I'll keep the PR open until the docs are added. |
|
I'm delighted to see this bug is finally fixed and will be merged, although I fixed and sent almost the same PR two years ago and left unanswered since then ;) |
|
Oh, thanks! That makes me feel like i'm not an idiot and there is really a bug) |
|
@amrael Sorry for that! I'm not actively using django-mobile myself, so this might have slipped past my unorganized self from two years ago 😁 Is one of you interested in taking over the maintenance of the project? |
|
Uhm, thanks, but I don't think so. I'm good with proposing PRs) |
|
😄 alright, keep it up. |
|
Would you merge the code? |
|
@gregmuellegger no worries, I figured you're too busy to maintain it at that time. |
…ddleware for compatibility
|
@gregmuellegger , does anything remain which blocks this pull-request from being merged? |
Fixed bug in `cache_page` decorator, splitting middleware in two
|
@ojomio Just released 0.7.0 including your changes: https://pypi.python.org/pypi/django-mobile/0.7.0 |
|
Thank you! |
It is necessary to introduce
HTTP_X_FLAVOURheader before standard DjangoCacheMiddlewarein requestand patch
Vary:headers before standard DjangoCacheMiddlewarein response as wellThus, nesting flavour decorator inside cache decorator is not correct and we need two separate flavour decorators for caching with flavour