I am trying to access a txt file in my website and fetch its contents that is hosted by 000webhost. I used this code:

void sendGET() //client function to send/receive GET request data.
 WiFiClient client;
 if (client.connect(host, httpPort)) {  //starts client connection, checks for connection
 client.println("GET /status.txt HTTP/1.1"); //download text
 client.println("Host: *****.000webhostapp.com");
 client.println("Connection: close");  //close 1.1 persistent connection
 client.println(); //end of get request
else {
 Serial.println("connection failed"); //error message if no client connect
bool rn = false;
while (client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
//    responsed = c;
if (rn == true) {
  if (c == '1') {
  else if (c == '0') {

if (c == '!') {
  rn = true;

client.stop(); //stop client
rn = false;

but in my serial monitor, it echoed

HTTP/1.1 200 OK
Date: Tue, 20 Nov 2018 06:26:41 GMT
Content-Type: text/plain; charset=UTF-8
Content-Length: 1
Last-Modified: Mon, 19 Nov 2018 10:01:12 GMT
Accept-Ranges: bytes
Server: awex
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Request-ID: 4575720f977969af975e822bc1e15eea
Age: 10203
X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:3128
Via: 1.1 localhost (squid/3.5.27)
Connection: close


why isn't it reading the content? i am new to this platform, thank you.

edit, the file contains only two characters. i used ! to indicate that the next number will be the one to store, and the next is either 0 or 1 based on the api i made. in short it is used to transfer my api's response to be read by arduino using esp8266

closed as off-topic by Juraj, VE7JRO, sempaiscuba, gre_gor, Greenonline Nov 21 '18 at 23:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – Juraj, VE7JRO, sempaiscuba, gre_gor, Greenonline
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    ! is not there. the length of the respose data is 1 as you can see in the Content-length header – Juraj Nov 20 '18 at 9:52
  • As I said, it is in the file that i want to read. It is to indicate that the next number will be the one to be checked if its either 1 or 0 based on the api i made that edits the text file. Arduino's job here is to check the value on the file and react to it. I have a code there that checks if the value that it read is equal to ! and prepare to react if it is equal. – Aldrine NAX Nov 20 '18 at 9:57
  • it is not in the response. you copy every byte to Serial Monitor. do you see the !? and the length is 1 and one char is there ('1') – Juraj Nov 20 '18 at 9:57
  • I just checked the file and ! is in there, can you point out other errors in my code? – Aldrine NAX Nov 20 '18 at 9:59
  • the problem is not in your arduino code.the response doensn't contain ! Content-Length: 1 – Juraj Nov 20 '18 at 10:02

Your connection to the web server is through a Squid caching proxy. It is delivering a cached version of the file:

X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:3128

The Age header shows you how long the page has been in the cache:

Age: 10203

That's been cached for about 2.8 hours.

You need to tell the cache not to get a cached version, but instead to always go to the server to get the latest copy. To do that you should be able to include a "no-cache" header in your request:

Cache-Control: no-cache

That should tell squid "Don't cache this page - get the real one".

You can also add the HTTP/1.0 version of the same thing:

Pragma: no-cache

That way if one doesn't work on that version of squid the other one should.

Not the answer you're looking for? Browse other questions tagged or ask your own question.