1

I'm required to speed up access to a specific website, which is terribly slow. I have no access to the source code/configuration of that server. After analysis, I figure out the problem:

  • The server is far from customer's location, so latency is high - about 400ms
  • The html pages have many <script src="..."> tags, each of which require a separate request to load.
  • The browser only send 6-8 requests at a time, thus it would take at least 5s to fetch all the js files for one page

Caching of the js files is not viable because js file name and content are dynamically generated by the server.

So I'm trying to set up a (reverse?) proxy server with low latency connection to the original server. When customer request a .html file, the proxy server should get the file from original server, parse it, find all <script src="...">, fetch the javascript, and embed the javascript code into <script> tag (and removing src="...") then return the bundled html. This way the browser doesn't need to send additional requests to get js files, and the latency doesn't accumulate

The question(s):

  • Is there a proxy server software with that feature available? Or maybe a nginx module/script?
  • If customer's browser support HTTP/2, will a HTTP/2 proxy server solve the issue?
  • Do you have any other solution to this problem?

Please help, thanks.

1

Google has developed an nginx and apache module with a lot of useful optimizations. One of them is javascript minification and concatenation. I have never tryed it but it seems to be what you are looking for https://developers.google.com/speed/pagespeed/module/filter-js-combine

Another solution would be using something like webpack to bundle all your javascript files. But it would require a few changes on your code base.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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