Downloading zip files by http

Everything that doesn't really have to do with Hollywood
Post Reply
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Downloading zip files by http

Post by amyren »

I had this issue that I thought was Hollywood messing with me.
I made a program where the server first create a folder on my ftp server and then uploads some files, some text files and a zip file.
My client program then use http to download these files. When the text files are updated and reuploaded from the server, I could see that they gets updated on the client.
But for some reason this is not the case for the zip file.
Even if the server updates the zip file, the client would only download the original zip file.

Using a web-browser and a ftp-client I did a few test. If I download the zipfile with the ftp-client I always gets the updated file. But when downloading with the browser it just gets the original zip file.
To verify that it was not the browser cache I tried another computer, but still getting the old file. Even if I delete the file on the ftp server, the file is downloadable.

My solution in my case is to change the download method to ftp.
But I still wonder why this is happening. Is this a common issue or is it something I should adress to my hosting service provider (hostinger)?
p-OS
Posts: 167
Joined: Mon Nov 01, 2010 11:56 pm

Re: Downloading zip files by http

Post by p-OS »

Maybe the remote server, your files are stored, has a proxy mechanism, caching often requested files.
You could try proxyignore http header in your http request

google for:
"Pragma"="no-cache"
"Expires"="-1">
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: Downloading zip files by http

Post by amyren »

I have now tried a few variants, both trying Pragma: and Cache-Control:, but I still could not get it to fetch the updated file.
Not sure if I use the correct syntax here, or if HURL supports the customheaders.

Code: Select all

DownloadFile(my_url$, {File = "my_file.zip", CustomHeaders = "Pragma: no-cache\r\n", Fail404 = True, Adapter = "hurl"})
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Downloading zip files by http

Post by airsoftsoftwair »

Have you tried it without hURL or do you need SSL?
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: Downloading zip files by http

Post by amyren »

My website was set to enforce https, so I havent tried without hurl.
But I just found that I do have the option to unforce https in the domain management, so I will try this and test without hurl later.
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: Downloading zip files by http

Post by amyren »

Have unforced https, and try to fetch the file without hurl now.
But still the file will not get updated.

Here are some of the different commands I have tried (Lines uncommented one at the time for each atempt)

Code: Select all

;DownloadFile(brett_dl$, {File = "virtbrett.zip", CustomHeaders = "Cache-Control: no-store, must-revalidate\r\n", Fail404 = True})
;DownloadFile(brett_dl$, {File = "virtbrett.zip", CustomHeaders = "Cache-Control: no-cache, must-revalidate\r\n", Fail404 = True})
;DownloadFile(brett_dl$, {File = "virtbrett.zip", CustomHeaders = "Cache-Control: no-cache\r\n", Fail404 = True})
;DownloadFile(brett_dl$, {File = "virtbrett.zip", CustomHeaders = "Cache-Control: must-revalidate\r\n", Fail404 = True})
DownloadFile(brett_dl$, {File = "virtbrett.zip", CustomHeaders = "Cache-Control:no-cache, no-store, must-revalidate, proxy-revalidate, Max-age=0, s-Max-age=0\r\n", Fail404 = True})
;DownloadFile(brett_dl$, {File = "virtbrett.zip", CustomHeaders = "Pragma: no-store, must-revalidate\r\n", Fail404 = True})
;DownloadFile(brett_dl$, {File = "virtbrett.zip", CustomHeaders = "Pragma: no-cache\r\n", Fail404 = True})
Are the syntax in my attempts above correct?
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Downloading zip files by http

Post by airsoftsoftwair »

Can you provide an MCVE that I can try here to see the issue? Otherwise it's hard to say what's going on.
Post Reply