Welcome Guest, Not a member yet? Register   Sign In
caching problem - my clients network caches my apps pages, serving the same page over and over

I have an issue with a client, their network seems to be aggressively caching my application. for example ... when a user logs in, they they have extra tools loaded unto their pages ... if 1 person on the network accesses the page, it's like their servers will only serve their users this page over and over again ... disregarding cookies and my various added header tags (added to combat this issue).

Even on password restricted pages ... if a user with a certain access level loads the page first, then it seems intermittently this same page is fetched over and over ... ignoring the access levels of other users. (for example ... user A might only see certain nav bar, but user B might have an enhanced nav bar with more options/links).

I'm at wits end ... i'm getting ready to add a microsecond hash to all urls! gasp!

Here are my headers ... i put them all in the header view as the first line ... is that a problem? does it need to be in the controller?

$this->output->set_header("Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT"); // Date in the past
$this->output->set_header("Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT"); // always modified
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
$this->output->set_header("Cache-Control: post-check=0, pre-check=1", FALSE);
$this->output->set_header("Pragma: no-cache");

I had something like this happen to me, with different users in the same network being logged in as each other if we used my app simultaneously. Never fixed it Sad

this is an ongoing issue with me with this client ... it's crazy though ... i feel like telling their server admins "how does internet access on your network even function correctly, do you even know it's broken?" ... but basically it'e my job to save face, even though I feel I'm doing things correctly. Their management might just write this off as inferior product.

But it really has made me think ... what other projects of mine are experiencing this issue? NOt my clients ... but their users ... I don't get it.

http://domain.com/app_url is jsut so damn clean ... their isp/proxy servers are just reusing it over and over.

[eluser]Phil Sturgeon[/eluser]
If use A (admin) logs in and user B (normal user) are seeing the same content from different computers this has nothing what-so-ever to do with browser cache.

You must have caching somewhere else, such as the built in Output library cache. With that enabled no matter what you set in your headers this cache will still exist for all users. Turn it off in the config.php.

I know it's not a browser caching issue. I'm thinking it's their proxy server. I'm not using the cache library ... the folder is blank.

The only line in my config file mentioning output is the output compression (gzip) ... which is set to true ... is this what you are referring too?

$config['compress_output'] = TRUE;

[eluser]Phil Sturgeon[/eluser]
My bad, not used cache in a while so forgot it is enabled on a per-page basis with a reference to output class to turn it on.

Are they using anything like Squid proxy to cache page content based on URL? If so I believe it can be configured to respect HTTP headers and so will not cache your app.

unfortunately, it's a really old version of Microsoft Internet Security & Acceleration Server ... and seems they don't really know how to configure it. Very frustrating!

I think the only sure fire way to fix this is to create unique URLS based on hashes ... so ...

/admin/tools will become /admin/tools/caga2dfpsdfa89d8fa90823

so in my html ...

and when fetched it will always drop in a new time hash and therefor a new URL every time.

(this would only be for inside, admin only pages)

very suckish!!!

[eluser]Phil Sturgeon[/eluser]
Best way to do that is to extend the Config library. Sounds nutty, but in the Config is a method named site_url() which is used for anchor(), base_url(), form_open(), etc.

Just add uniqid() onto the end of the returned result in there and it will work for all url's. In the future if you find a find a magical solution then you can remove it from there in one go too.

Something like:

class MY_Config extends CI_Config {
    function site_url($uri = '')
        if (is_array($uri))
            $uri = implode('/', $uri);

        if ($uri == '')
            $url = $this->slash_item('base_url').$this->item('index_page');
            $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
            $url = $this->slash_item('base_url').$this->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix;

        return $url.'/'.uniqid();


Edit: Noticed you mentioned this is only for admin pages. You could always throw a strpos('admin/', $url) too.

nice one ... that would work ... i just need to add a conditional statement to it based on whether or not it's the admin section that is being requested ... ummm ... hmmm ....????

[eluser]Phil Sturgeon[/eluser]
return $url . ( strpos($uri, '/admin') !== FALSE ? '/'.uniqid() : '' );

That will only add it to the end if /admin does not exist in the title. This is a hacky method to a hacky problem but as I said this means if the fix is found you can just delete this file and its all back to normal.

Theme © iAndrew 2016 - Forum software by © MyBB