1. Access CyberPanel Admin Panel: Begin by logging in to your CyberPanel admin panel.
  2. Navigate to Website Settings: Once logged in, navigate to the settings of the website for which you want to configure browser caching.
  3. Edit vHost Configuration: Locate the vHost configuration section. This is where you can specify directives for OpenLiteSpeed to follow when serving content for your website.
  4. Insert Caching Configuration: Copy and paste the following code into the vHost configuration, preferably within the appropriate context block:
  5. Save Configuration Changes: After inserting the caching configuration, save the changes to the vHost configuration.
  6. Restart OpenLiteSpeed: To ensure that the changes take effect, restart the OpenLiteSpeed web server.
context exp:^.*(woff|woff2|jpg|jpeg|png|css|js|ttf)$ {
  location                $DOC_ROOT/$0
    extraHeaders            <<<END_extraHeaders
    unset Cache-control
    set Cache-control public, max-age=31536000
  END_extraHeaders
}

The provided code snippet defines a context block that matches specific file extensions (e.g., woff, woff2, jpg, jpeg, png, css, js, ttf). Within this context, it sets the Cache-control header to specify caching directives for these resource types. The max-age directive indicates how long (in seconds) the browser should cache the resources. In this case, it’s set to 31536000 seconds, equivalent to one year.