[SalesForce] related list not getting updated in Salesforce Lightning

I have two objects – Project and Resource . Project is a lookup field on Resource.
So in Project there is a related list called Resources.

Now in Resource , I have created a list button "Add project Resource" which calls a VF page(having custom controller). There is a commandbutton on the VF page like this

<apex:commandButton value="Save" action="{!save}"/>

and in controller

public PageReference save()
{

 //....do some calculation
 //...insert a new resource....
   return new Pagereference('/'+project.id);
}

So basically it creates a new resource and navigates back to its parent project .
Problem this when I am Switching to lightning experience , it does navigate to the project record but its resource related list is not updated. I need to refresh the project record manually and then it shows the newly added resource in the resource related list.

Is there some cache problem ?

I have tried using sforce.one.navigateToSObject("{!project.id}") when its lightning but same problem occurs.

Please help.

Best Answer

Indeed, just redirecting to the record will not fire a refresh event. However, sforce.one.back takes a "refresh" parameter, so if you only need to go back to the record you were on (a "nav back") you can just use sforce.one.back(true).

There's an [example of this as a VF component][https://github.com/SalesforceFoundation/Cumulus/blob/dev/src/components/UTIL_NavigateBack.component] in the NPSP:

<apex:component >
    <apex:attribute name="recordId"
        description="The recordId to navigate to."
        type="Id"
        required="true"
        />
    <apex:attribute name="redirect"
        description="Prevent redirect unless set to true."
        type="Boolean"
        default="false"
        />

    <script type="text/javascript">
        var redirect = {!redirect};
        if (redirect) {
            if ((typeof sforce != 'undefined') && sforce && (!!sforce.one)) {
                // Manage navigation in Lightning Experience & Salesforce1
                    sforce.one.back(true);
            }
            else {
                var recordId = '{!recordId}';
                // Manage navigation in Salesforce Classic
                window.parent.location.href = '/' + recordId;
            }
        }
    </script>

</apex:component>