---
title: "Delayed"
language: "en"
type: "Symbol"
summary: "Delayed[expr] represents an expression whose evaluation is delayed until its value is externally requested. Delayed[expr, fmt] specifies that the result from evaluating expr should be given in format fmt. Delayed[expr, {fmt, rform}] specifies that the result should be given as a response of the form rform."
keywords: 
- browser refresh
- web computation
- dashboard
- status display
canonical_url: "https://reference.wolfram.com/language/ref/Delayed.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Cloud Functions & Deployment"
    link: "https://reference.wolfram.com/language/guide/CloudFunctionsAndDeployment.en.md"
  - 
    title: "Web Operations"
    link: "https://reference.wolfram.com/language/guide/WebOperations.en.md"
  - 
    title: "Automated Reports"
    link: "https://reference.wolfram.com/language/guide/AutomatedReports.en.md"
  - 
    title: "HTTP Requests & Responses"
    link: "https://reference.wolfram.com/language/guide/HTTPRequestsAndResponses.en.md"
related_workflows: 
  - 
    title: "Set Up a Web Gallery"
    link: "https://reference.wolfram.com/language/workflow/SetUpAWebGallery.en.md"
related_functions: 
  - 
    title: "Dynamic"
    link: "https://reference.wolfram.com/language/ref/Dynamic.en.md"
  - 
    title: "RuleDelayed"
    link: "https://reference.wolfram.com/language/ref/RuleDelayed.en.md"
  - 
    title: "APIFunction"
    link: "https://reference.wolfram.com/language/ref/APIFunction.en.md"
  - 
    title: "Defer"
    link: "https://reference.wolfram.com/language/ref/Defer.en.md"
  - 
    title: "ExportForm"
    link: "https://reference.wolfram.com/language/ref/ExportForm.en.md"
  - 
    title: "ResponseForm"
    link: "https://reference.wolfram.com/language/ref/ResponseForm.en.md"
  - 
    title: "AutoRefreshed"
    link: "https://reference.wolfram.com/language/ref/AutoRefreshed.en.md"
  - 
    title: "DocumentGenerator"
    link: "https://reference.wolfram.com/language/ref/DocumentGenerator.en.md"
---
# Delayed

Delayed[expr] represents an expression whose evaluation is delayed until its value is externally requested.

Delayed[expr, fmt] specifies that the result from evaluating expr should be given in format fmt.

Delayed[expr, {fmt, rform}] specifies that the result should be given as a response of the form rform.

## Details and Options

* ``Delayed`` is typically used with ``CloudDeploy`` to create a web page whose content is updated whenever the page is requested.

* The following options can be given:

|                             |          |                                                  |
| --------------------------- | -------- | ------------------------------------------------ |
| AllowedCloudExtraParameters | None     | what overall parameters to allow to be specified |
| CachePersistence            | 0        | how long to maintain a cache of results          |
| UpdateInterval              | Infinity | how often a browser should request an update     |

* With the option ``UpdateInterval -> t``, ``Delayed`` specifies that a web page should be updated in the web browser every ``t`` seconds when it is displayed.

* The option ``AllowedCloudExtraParameters`` specifies what additional query parameters governing evaluation of ``expr`` should be allowed.

* Possible result formats ``fmt`` in ``Delayed[expr, fmt]`` are:

|       |                                             |
| ----- | ------------------------------------------- |
| "fmt" | any format supported by ExportForm          |
| fun   | an arbitrary function to be applied to expr |

* ``Delayed[expr, "fmt"]`` is equivalent to ``Delayed[ExportForm[expr, "fmt"]]``.

* ``Delayed`` is also used to control the resource copying behavior of cloud functions such as ``DocumentGenerator``. Files and cloud objects qualified as ``Delayed`` are used in place.

## Examples (6)

### Basic Examples (3)

``Delayed`` specifies that the expression should not be evaluated until it is requested:

```wl
In[1]:= obj = CloudDeploy[Delayed[DateString[]]]

Out[1]= CloudObject["https://www.wolframcloud.com/obj/6a65c712-e1a1-4fd0-b9eb-90880145870a"]
```

Visit the link to view the deployed output:

```wl
[image]
```

---

Deploy a delayed evaluation that is converted to the ``"CSV"`` format:

```wl
In[1]:= obj = CloudDeploy[Delayed[RandomInteger[{1, 10}, {3, 7}], "CSV"]]

Out[1]= CloudObject["https://www.wolframcloud.com/obj/01e4b37c-fe38-4edc-ab93-5dcf8a083dce"]
```

Request the object from the cloud:

```wl
In[2]:= data = URLRead[obj, "Body"]

Out[2]=
"3,1,6,8,10,3,3
6,6,6,3,7,8,9
9,8,8,1,8,6,3
"
```

---

Deployed a delayed evaluation where the result is in the ``"CSV"`` format, but the overall response, with fields from ``EvaluationData``, is given in JSON:

```wl
In[1]:= obj = CloudDeploy[Delayed[RandomInteger[{1, 10}, {3, 7}], {"CSV", "JSON"}]]

Out[1]= CloudObject["https://www.wolframcloud.com/obj/1e5f6299-f250-4260-a60e-a47d55365c37"]
```

Request the object:

```wl
In[2]:= URLRead[obj, "Body"]

Out[2]=
"{
	\"StatusCode\":200,
	\"Success\":true,
	\"FailureType\":null,
	\"OutputLog\":[],
	\"Timing\":6.8e-2,
	\"AbsoluteTiming\":8.2e-2,
	\"Messages\":[],
	\"MessagesText\":[],
	\"MessagesExpressions\":[],
	\"InputString\":\"GenerateHTTPResponse[Delaye ...  {}|>]\",
	\"Result\":\"4,1,7,8,3,5,2\
8,1,10,10,5,4,6\
8,2,4,8,2,9,2\
\",
	\"ResultMeta\":{
		\"StatusCode\":200,
		\"ContentType\":\"text\\/csv;charset=iso-8859-1\",
		\"Headers\":{
			\"content-type\":\"text\\/csv;charset=iso-8859-1\"
		}
	}
}"
```

### Options (2)

#### CachePersistence (1)

Deploy a ``Delayed`` that gives the current time and caches its result for up to 3 seconds:

```wl
In[1]:= obj = CloudDeploy[Delayed[Now, "Text", CachePersistence -> Quantity[3, "Seconds"]]]

Out[1]= CloudObject["https://www.wolframcloud.com/obj/2c3b0ed0-94f8-4306-9981-a17b76a03322"]

In[2]:= Table[Pause[1];URLExecute[obj], {5}]

Out[2]= {DateObject[{2023, 5, 4, 13, 18, 11.442049}, "Instant", "Gregorian", -5.], DateObject[{2023, 5, 4, 13, 18, 11.442049}, "Instant", "Gregorian", -5.], DateObject[{2023, 5, 4, 13, 18, 11.442049}, "Instant", "Gregorian", -5.], DateObject[{2023, 5, 4, 13, 18, 15.195423}, "Instant", "Gregorian", -5.], DateObject[{2023, 5, 4, 13, 18, 15.195423}, "Instant", "Gregorian", -5.]}
```

#### UpdateInterval (1)

Deploy a ``Delayed`` that refreshes every 3 seconds when displayed in a web browser:

```wl
In[1]:= CloudDeploy[Delayed[Now, "Text", UpdateInterval -> 3]]

Out[1]= CloudObject["https://www.wolframcloud.com/obj/98e2994d-cf7d-4441-9b1a-d038d68bf474"]
```

### Possible Issues (1)

Since the default ``ExportForm`` of ``Delayed[expr]`` is ``HTMLFragment``, an expression evaluating to ``None`` will be returned as an empty string:

```wl
In[1]:=
computation = CloudPublish[Delayed[None]];
URLExecute[First[computation]]

Out[1]= ""
```

In order to get the correct value in the above example, specify the format of ``Delayed[expr]`` as Wolfram Language:

```wl
In[2]:=
computation = CloudPublish[Delayed[None, "WL"]];
URLExecute[First[computation]]

Out[2]= "None"
```

## See Also

* [`Dynamic`](https://reference.wolfram.com/language/ref/Dynamic.en.md)
* [`RuleDelayed`](https://reference.wolfram.com/language/ref/RuleDelayed.en.md)
* [`APIFunction`](https://reference.wolfram.com/language/ref/APIFunction.en.md)
* [`Defer`](https://reference.wolfram.com/language/ref/Defer.en.md)
* [`ExportForm`](https://reference.wolfram.com/language/ref/ExportForm.en.md)
* [`ResponseForm`](https://reference.wolfram.com/language/ref/ResponseForm.en.md)
* [`AutoRefreshed`](https://reference.wolfram.com/language/ref/AutoRefreshed.en.md)
* [`DocumentGenerator`](https://reference.wolfram.com/language/ref/DocumentGenerator.en.md)

## Related Guides

* [Cloud Functions & Deployment](https://reference.wolfram.com/language/guide/CloudFunctionsAndDeployment.en.md)
* [Web Operations](https://reference.wolfram.com/language/guide/WebOperations.en.md)
* [Automated Reports](https://reference.wolfram.com/language/guide/AutomatedReports.en.md)
* [HTTP Requests & Responses](https://reference.wolfram.com/language/guide/HTTPRequestsAndResponses.en.md)

## Related Workflows

* [Set Up a Web Gallery](https://reference.wolfram.com/language/workflow/SetUpAWebGallery.en.md)

## Related Links

* [An Elementary Introduction to the Wolfram Language: Creating Websites and Apps](https://www.wolfram.com/language/elementary-introduction/36-creating-websites-and-apps.html)
* [An Elementary Introduction to the Wolfram Language: Immediate and Delayed Values](https://www.wolfram.com/language/elementary-introduction/39-immediate-and-delayed-values.html)

## History

* [Introduced in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) \| [Updated in 2014 (10.0.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md)