function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HR Integrator HavilandHR Integrator Haviland 

Site goes "Under Construction" or "Unauthorized" until Page is Viewed Internally with "/apex/..."

I have been experiencing very odd Site behavior the past 3 days. Whenever a Change Set is deployed with Controllers/VF Pages used in the Site or even at other "random" times, users are redirected to the "Under Construction" or 'Unauthorized" Pages. If I go to an affected Page internally via /apex/MyAffectedPage, the Page will then be available externally on the Site.

The Site's Active Home Page is never affected. If viewing a Page externally, and it redirects to Under Construction Page, visiting any other Page (except for the Site's Active Home Page) will redirect to Under Construction Page. But if I view a single Page internally, the Page will then be available externally, but every other Page (except for the Site's Active Home Page) will redirect to Unauthorized Page instead.

I went to "Preview as Admin" in the Site when I was getting redirected to the Unauthorized Page, and I think it was showing an "api is not accessible" message. I have to wait for the issue to occur again before I can confirm this.

If the issue strikes, I need to visit every Page used in the Site to have the entire Site available externally again.

This is terrible because we're finding out the issue happened when our clients complain our Site is down. I am adding custom Under Construction and Unauthorized Pages that will email us whenever it's viewed so we can cut our response time down, but I don't have the slightest clue on how to fix the issue altogether. Somehow viewing the Page internally is changing something in the Salesforce Back-end which allows the Page to be viewed externally. And what could be the trigger which resets the Page's external access?

About the "random" events causing the issue: They happen less than a few times a day, and the last event happened overnight. Maybe it was triggered when Salesforce was resetting the 24 Hour Site Usage Limit.

Additional Exceptions: The Site has been very buggy. I've ran into the "api is not accessible" Message every now and again over the past couple of days. I deployed a Change Set, visited all the Pages and verified it was externally available, and then, a couple hours later, I got a "Class needs to be Compiled" Exception with "api is not accessible" being the root cause. I clicked "Compile All Classes" under Setup --> Apex Classes, and the issue was resolved. I've hardly ever ran into that issue, and it seems very odd that now it happens with the other issue.