Set CDN Cache Duration in SuiteScript for Enhanced Suitelet
Set CDN caching duration in SuiteScript to optimize Suitelet performance and reduce server load, improving overall response times.
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
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 Performance
- Non-Production Account Access with Account Warmer SuiteApp 2026.1
The Account Warmer SuiteApp for NetSuite 2026.1 optimizes access in non-production environments, significantly reducing load times.
- SCEM Automatic JavaScript Code Optimization in NetSuite 2026.1
SCEM introduces automatic JavaScript code optimization for better performance and security in NetSuite 2026.1.
- NetSuite Usage Optimization: Avoid Excessive Service Cons...
Optimize NetSuite usage by avoiding excessive consumption of resources to maintain peak performance in a multi-tenant environment.
- Home Page Performance Optimization in SuiteCommerce
Optimize slow home page loading times in SuiteCommerce using diagnostics and resource tracking methods.
Advertising
Reach Performance Professionals
Put your product in front of NetSuite experts who work with Performance every day.
Sponsor This Category