Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a sitemap.xml that runs in 1.5 GB.

How do I serve that sitemap.xml compressed from nginx such that it will be compressed only once and then served? Probably using caching too (if possible)

Also I periodically update the sitemap.xml. So in that case it compressed site map should be invalidated and the new one compressed

share|improve this question
    
I'm curious if this actually works? Is the content really that dynamic? Or are you not exporting lastmod times? I'm assuming for SEO, search engines probably rate proper Sitemaps implementations over static files as well. –  polynomial Oct 2 '11 at 18:13

2 Answers 2

up vote 1 down vote accepted
+50

Afaik, virtually every crawler/search engine understands sitemap.xml.gz.

Configure whatever application generates your sitemap.xml to also gzip it, and then just have Nginx serve that pre-compressed file. In Nginx's config add something like

location /sitemap.xml.gz
    add_header Cache-Control "public, must-revalidate";

In addition to that, you might also want to add a 301 redirect from sitemap.xml to sitemap.xml.gz.

share|improve this answer

You should have http_gzip_static_module enabled. Make an pre-compressed version of file with .gz extension and remove original file. Nginx will ungzip and serve it on the fly, and if you need to update it - just update compressed one.

http://translate.google.ru/translate?sl=ru&tl=en&js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fsysoev.ru%2Fnginx%2Fdocs%2Fhttp%2Fngx_http_gzip_static_module.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.