Stop jQuery .load response from being cached

前端 未结 14 1888
迷失自我
迷失自我 2020-11-22 03:54

I have the following code making a GET request on a URL:

$(\'#searchButton\').click(function() {
    $(\'#inquiry\').load(\'/portal/?f=searchBilling&pid=         


        
14条回答
  •  长情又很酷
    2020-11-22 05:00

    I noticed that if some servers (like Apache2) are not configured to specifically allow or deny any "caching", then the server may by default send a "cached" response, even if you set the HTTP headers to "no-cache". So make sure that your server is not "caching" anything before it sents a response:

    In the case of Apache2 you have to

    1) edit the "disk_cache.conf" file - to disable cache add "CacheDisable /local_files" directive

    2) load mod_cache modules (On Ubuntu "sudo a2enmod cache" and "sudo a2enmod disk_cache")

    3) restart the Apache2 (Ubuntu "sudo service apache2 restart");

    This should do the trick disabling cache on the servers side. Cheers! :)

提交回复
热议问题