Difference in httpget$()

Discussions relevant to the differences between LBB and LB4 which could affect code compatibility
Nixa
Posts: 2
Joined: Mon Aug 09, 2021 5:45 pm

Difference in httpget$()

Post by Nixa »

I had problem with httpget() from my arduino server.
There is difference in LB and LBB. LB doesen't cache data, while LBB does.
That made LBB read cached data on every update instead of fresh data from server.

By Richard's advice, I had to add "cache-controll: max-age=30" to my arduino response header to make cached data obsolete before next reading from server.
Later I found that it is posible to use httpget$() without cache.

My solution was to copy httpget$() function from lb45func.bas to my program and change:

Code: Select all

calldll #net, "InternetOpenUrlA", hnet as ulong, url$ as ptr, _
  "" as ptr, 0 as long, 0 as long, 0 as long, hurl as ulong
to

Code: Select all

calldll #net, "InternetOpenUrlA", hnet as ulong, url$ as ptr, _
  "INTERNET_FLAG_NO_CACHE_WRITE" as ptr, 0 as long, 0 as long, 0 as long, hurl as ulong
I gues, that would be better solution to prevent unnecessary writes to drive.
guest
Site Admin
Posts: 198
Joined: Tue Apr 03, 2018 1:34 pm

Re: Difference in httpget$()

Post by guest »

Nixa wrote: Mon Aug 09, 2021 6:01 pm Later I found that it is posible to use httpget$() without cache.
You are correct that there are two approaches: either the sending end can can specify that the data should not be cached, or the receiving end can specify that the cache is bypassed and the data fetched direct from the source. But although the effect may appear to be the same, they are not equivalent and which you use should depend on the circumstances.

If the data source is volatile, for example it's a webcam image or data which changes regularly, then you should add a Cache-Control header at the sending end. This is because (1) it's important that 'stale' data is not received, whoever the recipient is, and (2) you can specify how long the data should be cached, if at all. I believe that this is the case with your data.

If the data source is not volatile, or changes only infrequently, and the only reason to bypass the cache is because you believe it has been polluted, or you are concerned that the data may be very out of date, or you just don't trust it, then it makes sense for the receiving end to be in control.

But it definitely wouldn't be right for me to modify lb45func.bas to bypass the cache always, because that defeats the entire object of the cache in increasing speed and reducing internet traffic.
Nixa
Posts: 2
Joined: Mon Aug 09, 2021 5:45 pm

Re: Difference in httpget$()

Post by Nixa »

But it definitely wouldn't be right for me to modify lb45func.bas to bypass the cache always, because that defeats the entire object of the cache in increasing speed and reducing internet traffic.
I agree. That is why I copied httpget$() to my program and edit it from there.
Allso, I posted that here because function is working differently than LB and I couldn't find solution nor the cause. Maybe this will help someone else.

Edit:
Probably, correct aproach would be to change the name of function i have copied, to make it compatible with LB.