- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
10-28-2012 08:51 PM
I have a sites page, and it seems to work fine. It has a custom controller that retrieves some data from a custom object and the Contact object, displays the info to the user, and lets them submit an updated version to 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 age 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?
Solved! Go to Solution.
10-28-2012 09:56 PM
Have you added cache and expires attribute in <apex:page> tag?
cache : A Boolean value that specifies whether the browser should cache this page. If set to true, the browser caches the page. If not specified, this value defaults to false. For Force.com Sites pages, if this attribute is not specified, this value defaults to true.
expires: The expiration period for the cache attribute in seconds. If the cache attribute is set to true, but this attribute is not specified, this value defaults to zero. For Force.com Sites pages, if cache is not set to false, this value defaults to 600 seconds.
10-29-2012 09:33 AM
I have - there is a version of the page setup with caching, and one without - no difference. They both suffer from same issue...
12-11-2012 10:11 AM
In case anyone ends up here, I did finally work this out with help from this post:
I set up a debug page, included it as a sites page, and when the page failed, this debug page finally revealed the error.
My controller class has a test method in it, which in turn was referencing a second class - and that 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, 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...