Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP Get - Problem with data caching

Status
Not open for further replies.

Richard Guelzow

Programmer
Jan 6, 2022
22
US
Hello All - I am querying an online database[non-vfp] using an HTTP Get Call. The 1st query works properly and returns the current status of the online database. Each subsequent call to the database returns the data from the initial call despite the fact that the underlying data in the online database has changed. The only way that I am able to obtain refreshed data is to exit VFP and restart the application. I have tried releasing the Microsoft.XMLHTTP object and re-creating it. I have tried releasing the local variable that the HTTP object is tried to. So far nothing has helped, I keep receiving the cached data from the initial query. Here is my code as entered into the VFP Command box:

m.oHTTP = CREATEOBJECT('Microsoft.XMLHTTP')
m.oHTTP.Open("GET", ' .F.)
m.oHTTP.Send()
m.cResult = oHTTP.responseText()
? XMLTOCURSOR(m.cResult,'Smscursor',0)

Thanks in advance.
Richard
 
I would beg to differ.

I think it's the browsers job to request a page from the server - then to decide whether to ask again later or take from local cache.

If your browser never talks to the server, never asks for anything that isn't supplied from cache locally, then it cannot be the server that
is controlling it.

Now, fair enough if a browser asks for a page from the server there are two things to think about at the server side, firstly does the page
get served from the servers own cache, or does it reprocess it... but the request for a page has first to be made by some remote client (browser).

The second thing is whether that page has any cache control directives in it...



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Indeed you have one point, Griff.

If the browser already decides to answer the request itself with cached content, then it's its fault.
But it's the server that must send several cache-control headers as response to a log in request.
If you ever used google Pagespeed Insights, it recommends to cache static resources, that is to give cache-control headers that ask the browser to cache.
In turn it means also asking browsers to not cache things that shouldn't be cached.

But there are more caches than the browsers. First there only is a server side cache if you make use of things like redis or any other means to store a page you built to respond with that in further requests. But then there are CDNs and proxies.

Again, look at the mechanism of etags. They work best if a CDN is used, but they also can be used just between client and server.

Besides, I've never seen even the bad IE browser to cache something if it's sent with a Cache-Control: no-cache response header, or max-age=0.

Edit: And directives to not cache something are not the only potential, actually the cache only helps, of course, if it does cache things worth caching. And how it's done best so it doesn't serve stale things.
Sometimes it can even serve stale things. I bet an a search on any site matching one that was made in the previous few seconds can't have a different result, unless you let results depend on a user's profile, then it also won't matter what new results would be available, you can save the time reprocessing that. It's good enough for a few seconds at least, depending on the site traffic and data changes for longer. Unless you have to focus on real time most current results, but then again use a push strategy, that means a client makes a long life connection and the server can continually send new data which is processed when arriving. Webhooks can work that way.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top