khipster2016-02-27 04:13:44
khipster, 2016-02-27 04:13:44

AJAX request downloads file.txt. How to disable caching?

I do not want to use a crutch with adding a random parameter to the request.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
RubaXa, 2016-02-27

Browsers can safely ignore headers and cache to death, for example, Safari on iOS even caches POST, so the option with a unique key is not such a bad solution. You can only not shove it into the queryString, but make it part of the url (`/path/to/${uniq-id}/my-file.txt`), this will definitely work for all 146%.

riot26, 2016-02-27

maybe something like this:

header("Content-Type: content-type text/plain");
header("Expires: Mon, 26 Apr 1989 12:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

Mark Doe, 2016-02-27

Judging by the tags, you need to add something like this to .htaccess

<Files .txt>
    Header unset Cache-Control

nozzy, 2016-02-28

url: '/path_to_file/file.txt&r=' + (new Date()).getTime();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question