no-cache

I've read the "Too Off-Topic" message and it may look like I'm doing it against the rules but I am writing a program for FreeBSD and am having a problem with requests from a browser on Android. I think it is natural for me to seek help here.

In RFC 9111 (HTTP Caching) I read:

The no-cache response directive, in its unqualified form (without an argument), indicates that the response MUST NOT be used to satisfy any other request without forwarding it for validation and receiving a successful response; see Section 4.3.

This allows an origin server to prevent a cache from using the response to satisfy a request without contacting it, even by caches that have been configured to send stale responses.

In the header I have:

Code:
Cache-Control: no-cache


But the browser doesn't make any request and uses the cached page. I can turn off the tablet and turn it on on the next day and it will use the cached page without contacting the service.

Device - tablet Samsung
OS - Android
Browser - Chrome

I tried:

Code:
Cache-Control: no-cache, must-revalidate

with the same result. From Chrome and Edge on Windows I get a conditional request as expected. What am I missing?
 
If it's static content that's one thing but if it's page content that needs to be updated then that's another issue. Also, depending on the size of the content forcing no cache is resource heavy. It's best to focus on content rather than full page.

I would suggest pulling in content with JavaScript and setting a variable such as date/time to amend the content when it is retrieved. That will add unique data to the string and force the browser to download the content.

Edit: that is the solution that I use on my project. But the forced content is 16 bytes of data at the most. Otherwise the data transfer cost would be too high. So maybe for your project you retrieve once? But my project is an interval function so it could be very heavy if the content were larger.

EDIT: Another idea to avoid JavaScript is to use a server side language to generate a random number or string to move/rename content when it's served.

So, find content, generate random string, amend/rename content, log the new name and store somewhere, then retrieve. That's heavy on the server but not in the data transfer. That's kind of a crazy idea I guess but it will work.

I should add that I use this solution for my project as well. For some binary files.

Needed to edit this again. The solution that I actually use is copy and once copy is completed then deleting the previous file from the server to make sure the copy has succeeded first. But this is not a highly used function either. I can imagine high usage of this would lead to some serious server lag.

Either way the solutions are not specific to freebsd and solutions should be handled in your program and how it relates to the browser.

😁
 
No and to be honest I do not know how to do it. But what could have happened to the header? It is all in my apartment -

The debug facilities in Chrome and Firefox are very useful, and driven by menus so they aren't that hard to learn. Start by pressing F12 or right-click "inspect" and go from there.

Alternatively you can use the "-i flag" with curl, it will also display the headers.

You don't describe well enough what exactly you are doing for further help as-is.
 
Here's a good place for the ADB novice.

Thank you but on that site I get:

403
Sorry, you have been blocked from viewing this page.
This website is using a security service to protect itself from online attacks. You performed an action that triggered the service and blocked your request.

I just clicked your link. Probably it's because mine is a Russian IP address. :)
 
The debug facilities in Chrome and Firefox are very useful, and driven by menus so they aren't that hard to learn. Start by pressing F12 or right-click "inspect" and go from there.

I am having the problem on an Android tablet. Unfortunately, I do not know how to press F12 or right-click on that. And my fingers are not accustomed to manipulating the device - I am an old fogy not even owning a smartphone.

I tried that on Windows and couldn't find how to access the HTTP header - there's only an HTML document.

You don't describe well enough what exactly you are doing for further help as-is.

It is very simple. When I open the page, the beast doesn't send any request. On the FreeBSD side I see it do this:

Establish a connection
Send a request for /favicon.ico - my service responds with 404

That's all and it shows the page - apparently it gets it from its cache.

I can expose my service to the Internet, but I do not want to publish my IP address. If you do not mind, I can send it to you in a private message. You will see it yourself. If you have an Android. :)
 
Back
Top