[Django] #26073: Last-Modified http header not set to the latest last-mod in multi-maps sitemaps

9 views
Skip to first unread message

Django

unread,
Jan 12, 2016, 5:25:54 AM1/12/16
to django-...@googlegroups.com
#26073: Last-Modified http header not set to the latest last-mod in multi-maps
sitemaps
------------------------------+--------------------------------------------
Reporter: xblitz | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.9
contrib.sitemaps |
Severity: Normal | Keywords: sitemap last-mod Last-Modified
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------------
at
[https://github.com/django/django/blob/master/django/contrib/sitemaps/views.py#L46]
{{{
def sitemap(request, sitemaps, section=None,
template_name='sitemap.xml', content_type='application/xml'):

req_protocol = request.scheme
req_site = get_current_site(request)

if section is not None:
if section not in sitemaps:
raise Http404("No sitemap available for section: %r" %
section)
maps = [sitemaps[section]]
else:
maps = sitemaps.values()
page = request.GET.get("p", 1)

urls = []
for site in maps:
try:
if callable(site):
site = site()
urls.extend(site.get_urls(page=page, site=req_site,
protocol=req_protocol))
except EmptyPage:
raise Http404("Page %s empty" % page)
except PageNotAnInteger:
raise Http404("No page '%s'" % page)
response = TemplateResponse(request, template_name, {'urlset': urls},
content_type=content_type)
if hasattr(site, 'latest_lastmod'):
# if latest_lastmod is defined for site, set header so as
# ConditionalGetMiddleware is able to send 304 NOT MODIFIED
lastmod = site.latest_lastmod
response['Last-Modified'] = http_date(
timegm(
lastmod.utctimetuple() if isinstance(lastmod,
datetime.datetime)
else lastmod.timetuple()
)
)
return response
}}}

we can see that when it gets the ''''latest_lastmod'''' from '''site''' it
only really depends on which was the last '''site''' in '''maps''' which
might not always be the latest_lastmod from all items in maps.

I think this is a big SEO issue for websites that rely on their sitemaps
being indexed by search engines as I noticed my website did not seem to
have my newer Urls indexed by google since it probably saw the '''Last-
Modified''' http header was not being newer that what they currently had
(even if it contains new urls with newer last-mod)

--
Ticket URL: <https://code.djangoproject.com/ticket/26073>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 12, 2016, 5:27:32 AM1/12/16
to django-...@googlegroups.com
#26073: Last-Modified http header not set to the latest last-mod in multi-maps
sitemaps
-------------------------------------+-------------------------------------
Reporter: xblitz | Owner: xblitz
Type: Bug | Status: assigned
Component: contrib.sitemaps | Version: 1.9
Severity: Normal | Resolution:
Keywords: sitemap last-mod | Triage Stage:
Last-Modified | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by xblitz):

* status: new => assigned
* owner: nobody => xblitz
* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

I will first make a test-case in a pull

--
Ticket URL: <https://code.djangoproject.com/ticket/26073#comment:1>

Django

unread,
Jan 12, 2016, 6:45:19 AM1/12/16
to django-...@googlegroups.com
#26073: Last-Modified http header not set to the latest last-mod in multi-maps
sitemaps
-------------------------------------+-------------------------------------
Reporter: xblitz | Owner: xblitz
Type: Bug | Status: closed
Component: contrib.sitemaps | Version: 1.9
Severity: Normal | Resolution: duplicate

Keywords: sitemap last-mod | Triage Stage:
Last-Modified | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: assigned => closed
* resolution: => duplicate


Comment:

Duplicate of #25989 which already has a patch. Feel free to review it
using the PatchReviewChecklist and mark the ticket "Ready for checkin"
when it looks good.

--
Ticket URL: <https://code.djangoproject.com/ticket/26073#comment:2>

Reply all
Reply to author
Forward
0 new messages