RewriteEngine On


# =========================================
# LiteSpeed — Security & Cache Headers
# =========================================
# NOTE: If LSCache is active, its TTL settings override Cache-Control headers
# set here. Manage static-asset TTLs in the LiteSpeed admin panel or via
# LSCache directives instead of relying solely on the blocks below.
<IfModule LiteSpeed>
    Header set Permissions-Policy "picture-in-picture=*"
    Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
    Header set X-Content-Type-Options "nosniff"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
    # Disable ETags at the server level too — LiteSpeed re-adds them
    # independently of FileETag/Header directives. Finish the job in the
    # LiteSpeed admin: Configuration → Server → General → Smart Keep-Alive.
</IfModule>

# =========================================
# Cache-Control headers
# (If LSCache is active these are supplementary — set matching TTLs
# in the LiteSpeed admin panel so the two don't conflict.)
# ETags are disabled here AND should be disabled in the LiteSpeed admin
# (Configuration → Server → General) to prevent LiteSpeed re-adding them.
# =========================================
<FilesMatch "\.(woff2|avif|jpg|jpeg|png|gif|webp|svg|ico|flv|mp4|mpeg|pdf|swf)$">
    Header set Cache-Control "max-age=31536000, public, immutable"
    Header unset ETag
    FileETag None
</FilesMatch>

<FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=2592000, public, immutable"
    Header unset ETag
    FileETag None
</FilesMatch>

<FilesMatch "\.(html)$">
    Header set Cache-Control "max-age=3600, public"
</FilesMatch>

<FilesMatch "\.(php)$">
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header unset ETag
    FileETag None
</FilesMatch>

# =========================================
# robots.txt
# =========================================
<Files "robots.txt">
    ForceType text/plain
    SetHandler None
    Header set Cache-Control "max-age=3600, public"
    Header unset ETag
    FileETag None
</Files>

# =========================================
# mod_expires fallback
# NOTE: Under LiteSpeed + LSCache, these are typically ignored in favour
# of LSCache TTLs. Keep them as a fallback for non-cached/pass-through
# responses, but don't rely on them as the primary caching mechanism.
# =========================================
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault                          "access plus 1 month"
    ExpiresByType image/webp                "access plus 1 year"
    ExpiresByType image/avif                "access plus 1 year"
    ExpiresByType image/jpeg                "access plus 1 year"
    ExpiresByType image/png                 "access plus 1 year"
    ExpiresByType image/gif                 "access plus 1 year"
    ExpiresByType image/svg+xml             "access plus 1 year"
    ExpiresByType font/woff2                "access plus 1 year"
    ExpiresByType text/html                 "access plus 1 hour"
    ExpiresByType application/json          "access plus 1 day"
    ExpiresByType text/css                  "access plus 1 month"
    ExpiresByType application/javascript    "access plus 1 month"
</IfModule>


# =========================================
# Directory options
# =========================================
Options -Indexes +SymLinksIfOwnerMatch


# PHP settings
php_value date.timezone "UTC"

# Errors
php_flag display_errors Off
php_flag display_startup_errors Off
php_flag log_errors On
php_value error_log "/home/appbbsco/domains/petermartin.dev/jason-cms/logs/error.log"

# Sessions
php_value session.gc_maxlifetime 3600
#php_value session.save_path "/home/appbbsco/sessions"
php_value session.gc_probability 1
php_value session.gc_divisor 1000

# Upload temp directory
php_flag file_uploads On
#php_value upload_tmp_dir "/home/appbbsco/tmp"
