Hi all,

I want to propose a change to the LocaleMiddlware or CommonMiddleware and 
wanted to get some feedback first. Let's assume one uses both 
CommonMiddleware and LocaleMiddleware and APPEND_SLASH is set to True.

i18n_patterns = ('',
    url(r'^about/$', 'about')
)

If one requests http://example.com/about this currently results in a 
redirect chain:

http://example.com/en/about (302 or 301 - depending on 
LocaleMiddleware.response_redirect_class)
http://example.com/en/about/ (301)

For SEO reasons, one should keep redirect chains as short as possible [1]. 
It would be nice to only make one redirect directly to /en/about/ instead - 
at least if LocaleMiddleware uses the same kind of redirect as the 
CommonMiddleware uses.

In your opinion, is that something that is worth addressing?

It's pretty easy to add slash injection to the LocaleMiddleware, as it 
already checks whether a path with a slash appended would resolve to a 
valid URL [2].

Alternatively, one could check redirect targets in process_response of the 
CommonMiddleware, check for valid URLs and append slashes if needed. That 
would probably be cleaner, but AFAICS requires calling is_valid_path again.

Any thoughts?

I could open a ticket and submit a patch/tests/documentation if it had a 
chance of being integrated.

Thanks for your feedback, 
Ludwig

[1] http://www.jamesburton.net/chained-301-redirects-google-search-impact/
[2] 
https://github.com/django/django/blob/master/django/middleware/locale.py#L45

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/7f339dd9-9929-4d14-a6c7-4040e7166c96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to