I’m thinking about adding another static server to a web app, so I’d have static1.domain.tld and static2.domain.tld.
The point would be to use different domains in order to load static content faster ( more parallel connections at the same time ), but what ‘troubles’ me is “how to get user’s browser to see static1.domain.tld/images/whatever.jpg and static2.domain.tld/images/whatever.jpg as the same file” ?
Is there a trick to accomplish this with headers or I’ll have to define which file is on which server?
No, there’s no way to tell the browser that two URLs are the same — the browser caches by full URL.
What you can do is make sure you always use the same url for the same image. Ie. all images that start with A-M go on server 1, N-Z go on server 2. For a real implementation, I’d use a hash based on the name or something like that, but there’s probably libraries that do that kind of thing for you.