From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Web UI Builder and Data Dashboard

cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP GET only works once

Web UI Builder:

I have a device that responds to HTTP GET messages.

I made a simple vi that uses the HTTP GET String function connected to a string constant and WireShark to monitor Ethernet traffic.

When the vi is first run an HTTP message is sent and replied to.

If the vi is run again the message is not transmitted.

If the HTTP GET message is changed the new message will be transmitted. But not twice.

If LabVIEW Web UI Builder is closed and restarted the message will again be sent just once when run.

 

Why is the message only being sent once? It's like all outgoing messages are being tracked and only sent once.

0 Kudos
Message 1 of 3
(6,137 Views)

I think this is standard (but not always desirable) behavior of the networking stack that Web UI Builder uses. (On Windows, it's basically the built in/  Internet Explorer networking stack). After the first GET request with the same URL, if the server doesn't send no-cache headers, a cached result will be returned.

 

If you control the server that you're connecting to (and can add HTTP headers), try adding a no-cache header to the GET response. ("Cache-Control: no-cache" is the first one I'd try).

 

If you don't control the server you're connecting to / that doesn't work, another workaround is to append a query string parameter with a random number or timestamp. With this approach, the GET URL is always changing, so the caching behavior is disabled and the request should always go to the server.

(Something like this appended to the end of the URL:

UIBGetQueryString.jpg

or, "&n=[timeInTicks]" if you're already using other query parameters)

0 Kudos
Message 2 of 3
(6,129 Views)

I think it's caching also. I did a little reading about it and that makes sense.

 

The random number/time trick doesn't work because all the previous GET's are being cached.

 

Thanks for taking the time to reply! 🙂

0 Kudos
Message 3 of 3
(6,125 Views)