Wolfram Function Repository
Instantuse addon functions for the Wolfram Language
Function Repository Resource:
Equivalent to using Once, but will only cache results if evaluation was successful
ResourceFunction["OnceUnlessFailed"][expr] is equivalent to Once[expr], but does not cache results if expr evaluates to a failure or generates a message. 

ResourceFunction["OnceUnlessFailed"][expr,loc] caches results in the persistence location loc. 
Evaluate an expression inside OnceUnlessFailed:
In[1]:= 

Out[1]= 

Any subsequent evaluations of OnceUnlessFailed[expr] simply returns the previous result:
In[2]:= 

Out[2]= 

If a message is generated during evaluation, results are not cached:
In[3]:= 

Out[3]= 

In[4]:= 

Out[4]= 

Retrieve the ResourceFunction:
In[5]:= 

Out[5]= 

Retrieve the ResourceObject:
In[6]:= 

Out[6]= 

Specify an alternate persistence location:
In[7]:= 

Out[7]= 

The value is remembered even after a kernel restart:
In[8]:= 

In[9]:= 

Out[9]= 

Even if no message is generated, a result will not be cached if the output results in a failure (as determined by FailureQ):
In[10]:= 

In[11]:= 

Out[11]= 

Since the first evaluation resulted in a failure, the result is not cached:
In[12]:= 

Out[12]= 

The results are now cached:
In[13]:= 

Out[13]= 

Specify that the result of OnceUnlessFailed should be remembered only for 5 seconds:
In[14]:= 

Out[14]= 

In[15]:= 

Out[15]= 

After the time specified has elapsed, the value is recomputed:
In[16]:= 

Out[16]= 

Specify that a remembered value should expire at the beginning of next year:
In[17]:= 

Out[17]= 

Use cached cloud operations even if the local machine has an unreliable internet connection:
In[18]:= 

Out[19]= 

The result is only cached once it completes successfully:
In[20]:= 

Out[20]= 

In[21]:= 

Out[21]= 

Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License