Set CDN Cache Duration in SuiteScript for Enhanced Performance
Set CDN caching duration in SuiteScript to optimize response times. Enhance Suitelet performance with caching options.
TL;DR Opening
Setting the CDN cache duration in SuiteScript allows developers to control how long content is cached. This enhances performance, especially for Suitelets, by reducing the need for repetitive processing and improving load times.
What is CDN Caching?
CDN (Content Delivery Network) caching is a technique that allows frequently accessed content to be stored temporarily to minimize server load and improve response times for users. By setting an appropriate caching duration, developers can ensure that cached responses are delivered quickly without unnecessary delays.
Method Description
The setCdnCacheable method is used to specify CDN caching for a designated time period. It can be invoked within server scripts, enhancing Suitelet performance by reducing the load on server resources when the same content is repeatedly requested.
Returns
- Returns
void
Supported Script Types
- This method is applicable for server scripts.
Governance
- There are no governance limits associated with this method.
Module
- N/http Module
Parent Object
- This method belongs to the
http.ServerResponseobject.
Parameters
The method accepts an options parameter, which is a JavaScript object that determines the caching behavior. The following table outlines the parameters:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.type | enum | required | Sets the value of caching duration. Using http.CacheDuration, you can configure this value. If UNIQUE is specified with a Suitelet, the Suitelet will not be cached, ensuring it always processes fresh requests. |
Error Handling
When using this method, developers should be aware of potential error codes:
- Error Code:
SSS_MISSING_REQD_ARGUMENT- Message: Missing a required argument: {param name}
- Thrown If: The
options.typeparameter is not specified.
Syntax Example
This code snippet demonstrates how to use the setCdnCacheable method within your script:
// Example SuiteScript codeserverResponse.setCdnCacheable({ type: http.CacheDuration.MAX});This example sets the caching duration to the maximum allowed, optimizing the Suitelet responses.
Related Topics
- http.ServerResponse
- N/http Module
- SuiteScript 2.x Modules
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- The
setCdnCacheablemethod enables dynamic CDN caching management. - Use it to enhance Suitelet performance by avoiding redundant processing.
- Developers must specify the
options.typeto avoid errors related to missing parameters.
Frequently Asked Questions (4)
Is the setCdnCacheable method applicable to all script types in NetSuite?
Are there any governance limits associated with using the setCdnCacheable method?
What happens if the options.type parameter is not specified when using setCdnCacheable?
What is the role of the options parameter in the setCdnCacheable method?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Custom Tool Script Enhancements in NetSuite
Custom tool scripts in NetSuite gain execution log support and a new management page in February 16, 2026.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
