Nginx configuration questions

I wrote it based on the Nginx proxy configuration shown on the Collabora site.

There are different parts of it.

download, presentation and image upload

location ~ ^/(c|l)ool {
proxy_pass https://127.0.0.1:9980;
proxy_set_header Host $http_host;
}

I couldn’t get Collabora to work unless I did the following instead of it.

location ^~ /cool {
proxy_pass https://127.0.0.1:9980;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $http_host;
}

What is the difference between these?