Find your content:

Search form

You are here

Code Caching Issue?


I have a sites page, and it seems to work fine from a functional perspective. It has a custom controller that retrieves some data from a custom object and the Contact object, displays the data to the user, and lets them submit an updated version of the data into another custom object.

But after a certain amount of time (24-48 hours), when I go to the page I get a 'Not Authorized message'. After much testing, and thinking it was a a problem with css/statis resources, I have now found that the problem seems to be with the controller (i.e. a page with no references to css/static resources still fails)

When I get the error, I can login to SF and simply view the apex controller class in the usual Setup - Develop - Classes interface, and the public sites page then works again for another 24-48 hours.

What am I missing here? I have different versions of the page setup with cache enabled, and with cache set to false - they all fail.

Attribution to: BritishBoyinDC

Possible Suggestion/Solution #1

Is it possible the resource your dealing with has some sort of authentication required to load an element.

If so, than you would have a authentication cookie in your browser that would expire and not allow you to authenticate and load an element from the browser after some time.

Although I think authentication cookies expire faster than that.

Attribution to: jordan.baucke

Possible Suggestion/Solution #2

In case anyone ends up here, I did finally work this out with help from this post:

I set up a debug page as described in the post, included it as a sites page, and when the page failed, this debug page finally revealed the error.

My controller class had a test method in it, which in turn was referencing a second class - and that second class was trying to update a field it wasn't allowed to when running as a Sites user. So for reasons that aren't clear to me, the controller work fine for a while, and the test ran fine when logged in, but at some point, it would error out, and I could only fix it by viewing the class while logged in...

I only worked this out by following the link above, and setting up a debug page that I could access as the Sites User, which finally showed me the error - every other debug method provided no information...

Attribution to: BritishBoyinDC
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content