What I need
- Ability to hit an endpoint on my webserver multiple times in a single call to my sub
- Each http call is done asynchronously.
- Each http call is done with no caching / no cache busting workarounds which fill my cache.
- Each http calls is not slowed down much compared to a normal http call.
What I have tried
Given caching issues with MSXML2.XMLHTTP60
and issues with MSXML2.ServerXMLHTTP
on corporate networks, I am using WinHttp.WinHttpRequest.5.1
.
I have this code:
Sub winhttp_test()
Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.Open "GET", "http://localhost:6969/test/winhttp_1", True
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.setRequestHeader "Cache-Control", "max-age=0"
http.send
'Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.Open "GET", "http://localhost:6969/test/winhttp_2", True
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.setRequestHeader "Cache-Control", "max-age=0"
http.send
MsgBox "done"
End Sub
My server never sees the first request (even if I uncomment the commented line).
If I remove the MsgBox
call, then my server sees neither request. It's like the send won't work if the object is destroyed straight after the call.
If I use ServerXMLHTTP
on a machine with no network issues, I get the same issue.
(note: /test
is the path to the end point. So both calls are hitting the same endpoint but with a different parameter the the url. I've tried instead to use GET and POST paramters, but the issue remains the same).
How do I achieve the behaviour I need?