Error Handling in Server-Side SuiteScript Responses

Learn error handling using SuiteScript for managing CDN caching and server responses effectively.

·2 min read·View Oracle Docs

CDN caching management is crucial for optimizing web performance and ensuring efficient resource delivery. This article discusses error handling when setting CDN caching in SuiteScript, specifically within server-side scripts.

What is the Method for Setting CDN Caching?

The method setCdnCacheable allows developers to control CDN caching duration, significantly affecting how responses are handled. This method returns no output (void) and is specifically designed for server scripts.

Supported Script Types

  • Server Scripts: The setCdnCacheable method can only be utilized in server scripts. For more detailed information on the different types of SuiteScript, check the SuiteScript 2.x Script Types documentation.

Governance

This method does not impose governance limits, which means you can set CDN cacheable options without restrictions on execution times or limits.

Parameters for setCdnCacheable

The method accepts an options parameter that is a JavaScript object containing essential types:

ParameterTypeRequired / OptionalDescription
options.typeenumRequiredDetermines the caching duration; use values from http.CacheDuration.

Note: When invoked through a Suitelet, setting options.type to UNIQUE ensures that the Suitelet is executed every time its URL is requested, preventing any caching from occurring.

Common Errors

During implementation, you may encounter the following error:

Error CodeMessageThrown If
SSS_MISSING_REQD_ARGUMENTMissing a required argument: {param name}The options.type parameter is not specified.

Syntax Example

Here's a basic syntax example that demonstrates how to set the CDN cacheable settings for a server response. Note that this is non-functional as presented, but illustrates proper usage:

suitescript
1// Additional code can be placed here
2...
3serverResponse.setCdnCacheable({
4 type: http.CacheDuration.MAX
5});
6...
7// Remaining code can continue here

Conclusion

Incorporating proper error handling and understanding the CDN caching methods enhances the efficiency of SuiteScript server responses. By adhering to best practices, you can ensure your application provides the best performance possible.

Related Topics:

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • The setCdnCacheable method manages CDN caching in SuiteScript server responses.
  • It requires a valid options.type parameter specifying caching duration.
  • Errors can occur if required arguments are missing, specifically for caching options.
  • Understanding caching settings can significantly impact web performance.

Frequently Asked Questions (4)

Can the setCdnCacheable method be used in client scripts?
No, the setCdnCacheable method is specifically designed for use in server scripts within SuiteScript. It cannot be used in client scripts.
What happens if I don't specify the options.type parameter in setCdnCacheable?
If the options.type parameter is not specified when using setCdnCacheable, you will encounter an error with the code SSS_MISSING_REQD_ARGUMENT indicating a missing required argument.
Is there a governance limit on using the setCdnCacheable method?
No, using the setCdnCacheable method does not impose any governance limits, meaning there are no restrictions on execution times or limits related to its use.
What is the effect of setting options.type to 'UNIQUE' in a Suitelet?
Setting options.type to 'UNIQUE' in a Suitelet ensures that the Suitelet is executed every time its URL is requested, effectively preventing caching and ensuring the response is fetched from the server.
Source: Errors Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in SuiteScript

View all SuiteScript articles →