Welcome Guest, Not a member yet? Register   Sign In
redirect() and cache issues??
#1

[eluser]houdini2232[/eluser]
I have been using CodeIgniter for two or more years now but I've run into an issue today I've never encountered before.

We have a simple admin page that allows a user to activate/deactivate entries in the database. When they click "activate" or "deactivate", it goes to a link like this:

/admin/update/65/1

This would activate the entry with ID 65, for instance. This works fine. The database is updated. Then I simply redirect the user back to the page they were viewing (/admin), but the page does not reflect the updates. Instead, I have to manually refresh the page in order to see the changes. The page is somehow being cached and I've tried every browser. I've even tried adding the following code to all pages:

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />

It doesn't work. I've tried redirecting using CodeIgniter's redirect() function and using standard PHP headers (header('Location: /admin')). They both act the same.

What on earth could be causing this issue? It's happening in every single browser I've tested in thus far (Firefox/Chrome/Safari). The /admin/home page is cached even after I visit a few other pages and come back to that page later.

Using CodeIgniter 2.0.2
#2

[eluser]houdini2232[/eluser]
I have resolved this issue by redirecting back to the page with a random string at the end (ex: /admin/home/fdsafddf, /admin/home/dj38djdu).

I'd still love to know what is causing this though. I do believe it's some kind of security mechanism in CodeIgniter. If it were at the browser level I think I'd see more inconsistency between the different browsers.
#3

[eluser]Junaid Atique[/eluser]
well i think that was because of the cache. set expire headers to some previous data that will help not to cache any thing. try this.

Code:
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
        $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
        $this->output->set_header('Pragma: no-cache');
        $this->output->set_header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
#4

[eluser]beaufrusetta[/eluser]
Dude...I've got this same issue, and I can't figure it out for the life of me. I'm going to try this solution posted in the last reply, but there's got to be something wrong. I don't have anything set to cache - it just does it automatically. I was thinking it was a browser issue, but I've tried all browsers, and it can't be that they ALL have the same problem. Maybe they can...I dunno.

Either way...I don't know why anyone else hasn't experienced this problem. Maybe it's a setup issue?
#5

[eluser]Unknown[/eluser]
I have the same issue, but only in IE. I tried to setting header like 'Junaid' said, but not work for me.

Someone find a solution for this problem?
#6

[eluser]InsiteFX[/eluser]
In IE you have to place the header at the top and then place another one at the bottom of the html!

So you need to have two headers one at top and one at the bottom.
#7

[eluser]Unknown[/eluser]
I am having the exact same problem. Did anyone make any progress?
#8

[eluser]rip_pit[/eluser]
[quote author="Jeemusu" date="1339667823"]I am having the exact same problem. Did anyone make any progress?[/quote]

Same behavior spotted but i found no solution.
I tryed everything i could without success.
#9

[eluser]Coder Test[/eluser]
@summer Student:

Use ajax for both status change and pagination (if u have pagination) in order to avoid this issue

Me too gone through same issue as u faced now its working fine for me

Try it out.......

#10

[eluser]jto1[/eluser]
I had the same issue with the upload class. I used $this->output->cache(0) and it solved the issue. so give it a try and see if it works.




Theme © iAndrew 2016 - Forum software by © MyBB