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
MikeGillMikeGill 

Visualforce page caching issue

Hi All,

 

I have a visualforce page which I am displaying externally using sites (setting = Login Not Allowed).

 

I have specified the following in my page - cache="false"

 

 

<apex:page standardController="Vacancy__c" extensions="ExternalVacancyControllerExtension" title="Client Vacancy " showHeader="false" cache="false" >

I am finding if the user re-opens the page after updates, they are getting a cache version of the page instead of the page with elements rendered="false". If I hit command-r (on a mac BTW), I get the right page.

 

 

Is there a trick to ensure the page is loaded fresh each time?

 

 

 

 

 

bob_buzzardbob_buzzard

Can you explain a little more about what you mean by "elements rendered="false"?  Are you expecting items which weren't rendered to appear if the underlying data changes and the user causes a refresh?  Also, how is the user refreshing the page?

MikeGillMikeGill

Hi Bob,

 

When the Vacancy Status equals 'Form with Client' the field can be updated externally by the client, else it displays inline. 

 

Access to the page is via a link in an email. The client updates the page and saves the changes, which in turn updates the vacancy with the next status. Once the client confirms the changes, the page is locked by not having the status 'Form with Client'.

 

After they have submitted the changes, they could use the link in the original email to open the page again - at this point they presented with a cached version of the page (????)

 

Apart from the hard browser refresh - this approach seems to work

 

Inside my page I have the following - for each field I want to display, I have two pageBlockSectionItems. (See code below)

 

 

 

     <apex:pageBlockSectionItem rendered="{! Vacancy__c.Status__c == 'Form with client'}">      
            <apex:outputLabel value="Company Description:" for="compinfo" title="Please update, enter or attach any useful information about the company, such as its history, its current positioning and vision."/>
            <apex:inputField value="{!Vacancy__c.Company_Description__c}" id="compinfo" style="width:250px; height:100px;" />
            </apex:pageBlockSectionItem>
            
            <apex:pageBlockSectionItem rendered="{! Vacancy__c.Status__c != 'Form with client'}">      
            <apex:outputLabel value="Company Description:" for="compinfo" title="Please update, enter or attach any useful information about the company, such as its history, its current positioning and vision."/>
            <apex:outputField value="{!Vacancy__c.Company_Description__c}" id="compinfo" style="width:250px; height:100px;" />
            </apex:pageBlockSectionItem>

 

Hope this helps

 

Jon Mountjoy_Jon Mountjoy_

Where's the logic for flipping the status variable?

MikeGillMikeGill

Here you go

 

 

public  class ExternalVacancyControllerExtension {

       private final Vacancy__c vacancy;
                
                public ExternalVacancyControllerExtension(ApexPages.StandardController stdController) {
        this.vacancy = (Vacancy__c)stdController.getRecord();
        
        }
        
        
        public PageReference ConfirmUpdate() {

				vacancy.Status__c = 'Proofing';
                update vacancy;

                PageReference wrUrl = new PageReference('XXX');
                wrUrl.setRedirect(true);

                return wrUrl;
                }
                
         public PageReference SaveUpdate() {

                update vacancy;
                return null;

                
                }
                
                
        
        

}

 

 

Jon Mountjoy_Jon Mountjoy_

Hmm - looks ok.  Can you confirm your form calls ConfirmUpdate() and NOT SaveUpdate()?   (I can't tell - you don't show it)

MikeGillMikeGill

Thanks Jon 

 

Here you go - pretty basic stuff

 

    

<apex:page standardController="Vacancy__c" extensions="ExternalVacancyControllerExtension" title="Client Vacancy " showHeader="false" cache="false" >

   <apex:form > 
   
    <apex:composition template="{!$Site.Template}"> 
  <apex:define name="body"> 
   <apex:pageMessages />
    <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em;"/>
      <apex:pageBlock title="" mode="edit" id="thePageBlock" >
        <apex:pageBlockButtons >
        <apex:commandButton value="Save Changes" action="{!SaveUpdate}" />
           <apex:commandButton value="Confirm & send" action="{!ConfirmUpdate}" rendered="{! Vacancy__c.Status__c == 'Form with client'}" />
           <apex:commandButton value="Cancel" action="{!Cancel}"/>
        </apex:pageBlockButtons>

 

 

Sometimes it works, sometimes it doesn't - seems a little inconsistent

 

Maybe this is not the best approach ???

 

jls_74_txjls_74_tx

Mike,

 

Did you find a solution to this problem?  I have the exact same issue and I'm approaching my clients in the exact same way (link in an email, ect.)

 

Thank You,

Jodi

MikeGillMikeGill
This issue resolved itself in the end, I don't remember changing anything specifically after this thread... I can post all the code if you like. What browser is your client using?
jls_74_txjls_74_tx

It's ok....I added the cache="false" attribute to my page and it works on all 3 browsers also.  Thank you for following up with me.

 

Jodi

AAkonsultPtyLtdAAkonsultPtyLtd

I had a similar problem where I had found the my page was not correctly initialising the controller. If I put cache="false" then it works.

 

I did want to use caching as much as possible, but wanted the controller to be initialised again, so what I did is vary the URL in my wizard with by adding&cacheControl='+system.now().format('yyyyMMddHHmmssFFF') to make it unique for each page view.