Fortinet black logo

RAM cache commands

Copy Link
Copy Doc ID 42c4d1e2-47b9-11ea-9384-00505692583a:93854
Download PDF

RAM cache commands

Note:

  • FortiADC can be configured to do RAM caching.
  • Certain URI can be excluded from caching.
  • Further, FortiADC supports dynamic caching in which certain URIs are cached for a specified period of
  • time and accessing some other URIs will invalidate their caching.
  • Note that dynamic caching is identified by a configured ID.
  • FortiADC script allows the user to control these behaviors and check the caching status.
  • Allows you to disable caching (both cache hit and cache store).
  • Allows you to disable exclude URI check.
  • Allows you to disable dynamic cache check.
  • Allows you to disable dynamic cache invalid check.
  • Allows you to directly enable dynamic caching with a given ID and age.
  • Allows you to invalidate a given dynamic cache indexed by its ID
  • Allows you to check whether a response is from cache or not, if yes, regular cache or dynamic cache
  • Allows you to check whether a response is been caching or not, if yes, regular cache or dynamic cache
  • Allows you to replace the default key (the URI) with any customized key
  • Allows you to drop an ongoing caching operation
  • Allows you to check its cache status for a given URI key: its cache ID and hit counts .

Please make sure RAM caching configuration is selected in the HTTP or HTTPs profile.

HTTP:exclude_check_disable()

Used to disable the exclude URI check.

Syntax

HTTP:exclude_check_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

if HTTP:exclude_check_disable() then

debug("set HTTP:exclude_check_disable: true\n");

else

debug("set HTTP:exclude_check_disable: Fail");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: cache_disable()

Used to disable caching(both cache hit and cache store).

Syntax

HTTP: cache_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

HTTP:cache_disable()

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_check_disable()

Used to disable dynamic caching check.

Syntax

HTTP: dyn_check_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

HTTP:dyn_check_disable

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_invalid_check_disable()

Used to disable dynamic invalid check caching.

Syntax

HTTP:dyn_invalid_check_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

HTTP:dyn_invalid_check_disable()

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_cache_enable(t)

Used to enable dynamic caching directly.

Syntax

HTTP:dyn_cache_enable(t);

Arguments

Name Description

t

A table which specifies the id an age of caching.

Examples

when HTTP_REQUEST {

t={}

t["id"] = 1;

t["age"] = 20; --in seconds

ret=HTTP:dyn_cache_enable(t)

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: cache_user_key(t)

Used to set customized key to replace the default used key.

Syntax

HTTP: cache_user_key(t);

Arguments

Name Description

t

A table which specifies the caching uri.

Examples

when HTTP_REQUEST {

url = HTTP:uri_get()

new_url = url.."external";

t={};

t["uri"] = new_url

HTTP:cache_user_key(t)

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_cache_invalid(t)

Used to invalid a certain dynamic cache given by id.

Syntax

HTTP: dyn_cache_invalid(t);

Arguments

Name Description

t

A table which specifies the cache id.

Examples

when HTTP_REQUEST {

t={}

t["id"] = 1 --between 1 and 1023

ret = HTTP:dyn_cache_invalid(t);

}

FortiADC version: V5.3

Used in events:

Used in HTTP_REQUEST / HTTP_RESPONSE

HTTP: cache_check(t)

Used to check whether cached or not for a certain URI.

Syntax

HTTP: cache_check(t);

Arguments

Name Description

t

A table which specifies the cache uri.

Examples

when HTTP_REQUEST {

t={}

t["uri"] = "/3.htm";

ret=HTTP:cached_check(t)

if ret then

debug("cached with id %s\n", ret);

else

debug("not cached\n");

end

}

FortiADC version: V5.3

Used in events:

Used in HTTP_REQUEST / HTTP_RESPONSE

HTTP: cache_hits(t)

Used to check the cache hit count for a certain URI.

Syntax

HTTP: cache_hits(t);

Arguments

Name Description

t

A table which specifies the cache uri.

Examples

when HTTP_REQUEST {

t={}

t["uri"] = "/3.htm";

ret=HTTP:cache_hits(t)

if ret then

debug("cache hit count %s\n", ret);

else

debug("not cached\n");

end

}

FortiADC version: V5.3

Used in events:

Used in HTTP_REQUEST / HTTP_RESPONSE

HTTP: res_caching()

Used to check whether the response is been caching.

Syntax

HTTP: res_caching();

Arguments: N/A

Examples

when HTTP_RESPONSE {

id = HTTP:res_caching();

if id then

debug("HTTP:res_caching() response caching with id %s !!!!\n", id);

else

debug("HTTP:res_caching() response NOT caching\n");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_RESPONSE

HTTP:res_cached()

Used to check whether the response is from cache or not.

Syntax

HTTP: res_cached();

Arguments: N/A

Examples

when HTTP_RESPONSE {

ret = HTTP:res_cached();

if ret then

debug("HTTP:res_cached() response from cache !!!!\n");

else

debug("HTTP:res_cached() response NOT from cache\n");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_RESPONSE

HTTP:caching_drop()

Used to drop the ongoing caching.

Syntax

HTTP:caching_drop();

Arguments: N/A

Examples

when HTTP_RESPONSE {

ret=HTTP:caching_drop()

if ret then

debug("script dropping caching: True\n")

else

debug("script dropping caching: False\n");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_RESPONSE

RAM cache commands

Note:

  • FortiADC can be configured to do RAM caching.
  • Certain URI can be excluded from caching.
  • Further, FortiADC supports dynamic caching in which certain URIs are cached for a specified period of
  • time and accessing some other URIs will invalidate their caching.
  • Note that dynamic caching is identified by a configured ID.
  • FortiADC script allows the user to control these behaviors and check the caching status.
  • Allows you to disable caching (both cache hit and cache store).
  • Allows you to disable exclude URI check.
  • Allows you to disable dynamic cache check.
  • Allows you to disable dynamic cache invalid check.
  • Allows you to directly enable dynamic caching with a given ID and age.
  • Allows you to invalidate a given dynamic cache indexed by its ID
  • Allows you to check whether a response is from cache or not, if yes, regular cache or dynamic cache
  • Allows you to check whether a response is been caching or not, if yes, regular cache or dynamic cache
  • Allows you to replace the default key (the URI) with any customized key
  • Allows you to drop an ongoing caching operation
  • Allows you to check its cache status for a given URI key: its cache ID and hit counts .

Please make sure RAM caching configuration is selected in the HTTP or HTTPs profile.

HTTP:exclude_check_disable()

Used to disable the exclude URI check.

Syntax

HTTP:exclude_check_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

if HTTP:exclude_check_disable() then

debug("set HTTP:exclude_check_disable: true\n");

else

debug("set HTTP:exclude_check_disable: Fail");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: cache_disable()

Used to disable caching(both cache hit and cache store).

Syntax

HTTP: cache_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

HTTP:cache_disable()

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_check_disable()

Used to disable dynamic caching check.

Syntax

HTTP: dyn_check_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

HTTP:dyn_check_disable

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_invalid_check_disable()

Used to disable dynamic invalid check caching.

Syntax

HTTP:dyn_invalid_check_disable();

Arguments: N/A

Examples

when HTTP_REQUEST {

HTTP:dyn_invalid_check_disable()

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_cache_enable(t)

Used to enable dynamic caching directly.

Syntax

HTTP:dyn_cache_enable(t);

Arguments

Name Description

t

A table which specifies the id an age of caching.

Examples

when HTTP_REQUEST {

t={}

t["id"] = 1;

t["age"] = 20; --in seconds

ret=HTTP:dyn_cache_enable(t)

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: cache_user_key(t)

Used to set customized key to replace the default used key.

Syntax

HTTP: cache_user_key(t);

Arguments

Name Description

t

A table which specifies the caching uri.

Examples

when HTTP_REQUEST {

url = HTTP:uri_get()

new_url = url.."external";

t={};

t["uri"] = new_url

HTTP:cache_user_key(t)

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_REQUEST

HTTP: dyn_cache_invalid(t)

Used to invalid a certain dynamic cache given by id.

Syntax

HTTP: dyn_cache_invalid(t);

Arguments

Name Description

t

A table which specifies the cache id.

Examples

when HTTP_REQUEST {

t={}

t["id"] = 1 --between 1 and 1023

ret = HTTP:dyn_cache_invalid(t);

}

FortiADC version: V5.3

Used in events:

Used in HTTP_REQUEST / HTTP_RESPONSE

HTTP: cache_check(t)

Used to check whether cached or not for a certain URI.

Syntax

HTTP: cache_check(t);

Arguments

Name Description

t

A table which specifies the cache uri.

Examples

when HTTP_REQUEST {

t={}

t["uri"] = "/3.htm";

ret=HTTP:cached_check(t)

if ret then

debug("cached with id %s\n", ret);

else

debug("not cached\n");

end

}

FortiADC version: V5.3

Used in events:

Used in HTTP_REQUEST / HTTP_RESPONSE

HTTP: cache_hits(t)

Used to check the cache hit count for a certain URI.

Syntax

HTTP: cache_hits(t);

Arguments

Name Description

t

A table which specifies the cache uri.

Examples

when HTTP_REQUEST {

t={}

t["uri"] = "/3.htm";

ret=HTTP:cache_hits(t)

if ret then

debug("cache hit count %s\n", ret);

else

debug("not cached\n");

end

}

FortiADC version: V5.3

Used in events:

Used in HTTP_REQUEST / HTTP_RESPONSE

HTTP: res_caching()

Used to check whether the response is been caching.

Syntax

HTTP: res_caching();

Arguments: N/A

Examples

when HTTP_RESPONSE {

id = HTTP:res_caching();

if id then

debug("HTTP:res_caching() response caching with id %s !!!!\n", id);

else

debug("HTTP:res_caching() response NOT caching\n");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_RESPONSE

HTTP:res_cached()

Used to check whether the response is from cache or not.

Syntax

HTTP: res_cached();

Arguments: N/A

Examples

when HTTP_RESPONSE {

ret = HTTP:res_cached();

if ret then

debug("HTTP:res_cached() response from cache !!!!\n");

else

debug("HTTP:res_cached() response NOT from cache\n");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_RESPONSE

HTTP:caching_drop()

Used to drop the ongoing caching.

Syntax

HTTP:caching_drop();

Arguments: N/A

Examples

when HTTP_RESPONSE {

ret=HTTP:caching_drop()

if ret then

debug("script dropping caching: True\n")

else

debug("script dropping caching: False\n");

end

}

FortiADC version: V5.3

Used in events:

Only used in HTTP_RESPONSE