diff --git a/index-wp-redis.php b/index-wp-redis.php
index 8e7beb4c2e265a143f08542bec4adab1af011eaf..9ff74269ec9e97d4424a46424b77da31f0c2ca72 100644
--- a/index-wp-redis.php
+++ b/index-wp-redis.php
@@ -159,7 +159,7 @@ function wp_redis_cache_set_device_key( $key ) {
  * @return string
  */
 function wp_redis_cache_get_device_type() {
-	$ua = $_SERVER['HTTP_USER_AGENT'];
+	$ua = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
 
 	if ( empty( $ua ) ) {
 		return 'desktop';