如何使用django.contrib.syndication.views设置缓存控制

如何使用django.contrib.syndication.views设置缓存控制,django,caching,syndication,Django,Caching,Syndication,我尝试使用Cache\u Control()(属于django.views.decorators.Cache)在中设置Cache-ControlHTTP头,但没有成功: from django.contrib.syndication.views import Feed from django.utils.feedgenerator import Atom1Feed import lxml.html import requests class TestFeed(Feed): feed_t

我尝试使用
Cache\u Control()
(属于
django.views.decorators.Cache
)在中设置
Cache-Control
HTTP头,但没有成功:

from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
import lxml.html
import requests

class TestFeed(Feed):
    feed_type = Atom1Feed
    language = 'zh-Hant-TW'
    link = 'https://www.example.com/feed'
    title = 'Sample feed'

    def items(self):
        s = requests.Session()
        r = s.get(self.link)
        body = lxml.html.fromstring(r.text)
        items = body.cssselect('.item a')

        return items

    def item_description(self, item):
        img = item.cssselect('img')[0]
        img.set('src', img.get('data-src'))
        content = lxml.etree.tostring(item, encoding='unicode')

        return content

    def item_link(self, item):
        link = item.get('href')

        return link

    def item_title(self, item):
        title = item.get('title')

        return title
跟踪之后,似乎不太可能使用decorator将HTTP头添加到HTTP响应对象中

是否有任何解决方法来实现这一点