danney1 / cool-php-captcha

Automatically exported from code.google.com/p/cool-php-captcha
GNU General Public License v3.0
0 stars 0 forks source link

missing headers #6

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
in version 0.3 is problem with headers

example-form.php >>
line 81:    document.getElementById('captcha').src='captcha.php?'+Math.random();

why did you use Math.random() ??? to prevent caching?

that bad way... correct way is remove this
document.getElementById('captcha').src='captcha.php';

and add to captcha.php
add line 471: 
header('Date: Tue, 31 Aug 2010 05:27:21 GMT', true);  // current time 
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); // time in past
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0');
header('Pragma: no-cache');

Original issue reported on code.google.com by svecp...@gmail.com on 31 Aug 2010 at 5:32

GoogleCodeExporter commented 8 years ago
I'm not sure about this change. In previos tests i've found some problems using 
header() to avoid cache.

I'm planning to add the header() functions, but i'll left Math.random()

Original comment by joserodr...@gmail.com on 1 Sep 2010 at 4:54

GoogleCodeExporter commented 8 years ago
I personally use these headers as I have found them to work all the time.

    function nocache() {
        header("Expires: Tue, 01 Jan 1970 06:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
        header("Cache-Control: post-check=0, pre-check=0", false);
        header("Pragma: no-cache");
    }

Original comment by neomaxim...@gmail.com on 23 Nov 2012 at 10:20