I installed mod_pagespeed on my dedicated server. but when i configure varnish on this server i got error max age should to be 1. I need to know that can we use both varnsih and mod_pagespeed on same url. Like can it both work well if both are working on server.
As well as installing mod_pagespeed you need to set it up correctly:
You will also have to make sure your version of mod_pagespeed supports 'Varnish' as this is currently an 'experimental feature'.
I dont see any good reasoning to have both. They do pretty much the same thing, which one to choose - i think it's more of a taste preference.
According to Varnish guys you'll be able to speed up delivery by 300x-1000x factor, which seems a little suspicious to me. The numbers are to unreal.
Accroding to this PageSpeed Module Results article, you can cut loading times and data size by up to 90%, which would be equivalent to 10x factor. And this number is still ridiculously drastic improvement, however seems more realistic.
Personally, I'm mod_pagespeed fan, and, considering the fact, that I have seen numbers get cut down by 50%-90% in my own tests, I would go with MPS rather than Varnish.