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
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
- Account Warmer SuiteApp in NetSuite 2026.1
Account Warmer SuiteApp optimizes performance for infrequently accessed non-production accounts in NetSuite 2026.1. Introduction
- 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.
- Group Cache Invalidation for Improved Performance in NetSuite
Group cache invalidation in NetSuite enhances performance by reducing individual requests when uploading files or using SOAP web services.
- Cursor Tracking Implementation with jQuery Performance
Implement cursor tracking in jQuery using the throttle method for optimized performance and efficient mouse movement handling.
Advertising
Reach Performance Professionals
Put your product in front of NetSuite experts who work with Performance every day.
Sponsor This Category