2

When recieving a http post in GAE, I download a txt file from another server, do some parsing, and return the info. However, there seems to be a delay when I update this txt file and try to access it through GAE. Here's a step by step explanation:

  1. I update a txt file on server A.

  2. I verify that the txt file is updated by accessing the txt file on server A.

  3. I notice a 5-10 min delay when accessing the same txt file through GAE(which fetches the txt from server A).

Maybe this the problem isn't GAE caching, but what else could it be?

Emir Kuljanin
  • 3,881
  • 1
  • 25
  • 30
  • 1
    Why don't you check the log to see if GAE downloads the file successfully? You could write the file's length/hash to log to check that new content is received. – Peter Knego Mar 25 '12 at 20:58
  • I don't understand. I already know that GAE downloads the file successfully every time. It's just the wrong file. The file GAE downloads is lagging 5-10 minutes from the actual file. I confirmed this by downloading the file through my browser and comparing it to the file that I download through GAE. – Emir Kuljanin Mar 25 '12 at 21:02
  • @PeterKnego is suggesting you check the logs on the machine that's serving the file, to see if you're getting a request from App Engine, which will tell you if it's caching. – Nick Johnson Mar 26 '12 at 09:04

1 Answers1

4

Try setting client cache control in your GAE URL fetch code:

URL urlObj = new URL(url); 
HttpURLConnection connection = (HttpURLConnection) 
urlObj.openConnection(); 
connection.addRequestProperty("Cache-Control", "no-cache,max-age=0"); 
connection.addRequestProperty("Pragma", "no-cache"); 

It seems to work for some people.

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154