# xspeed/1.0.0/includes/class-server.php

xSpeed Cache: AI-Powered Performance Hub with MCP, Caching &amp; CDN, version 1.0.0. 72 lines.

- Page: https://pluginprobe.com/plugins/xspeed/1.0.0/code/includes/class-server.php
- Raw: https://pluginprobe.com/plugins/xspeed/1.0.0/raw/includes/class-server.php
- Modified: 2026-05-27T11:31:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/xspeed/1.0.0/code/includes/class-server.php#L10-L20`.

```php
<?php
/**
 * Server / SAPI detection.
 *
 * Used by Gzip and the UI to decide which optimizations are server-applied
 * (Apache / LiteSpeed via .htaccess) vs. require manual config (nginx).
 *
 * @package XSpeed
 */

namespace XSpeed;

defined( 'ABSPATH' ) || exit;

class Server {

	const APACHE    = 'apache';
	const LITESPEED = 'litespeed';
	const NGINX     = 'nginx';
	const IIS       = 'iis';
	const UNKNOWN   = 'unknown';

	public static function type() {
		global $is_apache, $is_nginx, $is_IIS, $is_iis7;

		$signature = self::server_signature();

		if ( false !== stripos( $signature, 'litespeed' ) ) {
			return self::LITESPEED;
		}
		if ( ! empty( $is_apache ) || function_exists( 'apache_get_modules' ) || false !== stripos( $signature, 'apache' ) ) {
			return self::APACHE;
		}
		if ( ! empty( $is_nginx ) || false !== stripos( $signature, 'nginx' ) ) {
			return self::NGINX;
		}
		if ( ! empty( $is_IIS ) || ! empty( $is_iis7 ) || false !== stripos( $signature, 'microsoft-iis' ) ) {
			return self::IIS;
		}

		// Fallback: presence of .htaccess implies an Apache-compatible host.
		if ( file_exists( ABSPATH . '.htaccess' ) ) {
			return self::APACHE;
		}

		return self::UNKNOWN;
	}

	/**
	 * Whether the server respects .htaccess / web.config-style file-based config.
	 */
	public static function supports_htaccess() {
		$t = self::type();
		return self::APACHE === $t || self::LITESPEED === $t;
	}

	/**
	 * GZIP support category for the UI:
	 *   'auto'   — toggling writes server config (Apache / LiteSpeed)
	 *   'manual' — must be configured outside the plugin (nginx, IIS, unknown)
	 */
	public static function gzip_mode() {
		return self::supports_htaccess() ? 'auto' : 'manual';
	}

	private static function server_signature() {
		return isset( $_SERVER['SERVER_SOFTWARE'] )
			? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) )
			: '';
	}
}

```
