• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Php.ini Configuration: opcache.save_comments

December 19, 2023

Php.ini Configuration: opcache.save_comments

When it comes to optimizing the performance of your PHP applications, the configuration of the php.ini file plays a crucial role. One of the key settings that can significantly impact the performance of your PHP scripts is the opcache.save_comments directive.

Understanding opcache.save_comments

The opcache.save_comments directive is a configuration option available in the PHP OPcache extension. OPcache is a built-in PHP extension that improves the performance of PHP scripts by caching precompiled bytecode in shared memory, reducing the need for PHP to load and parse scripts on each request.

By default, the opcache.save_comments directive is set to “0” (disabled). When disabled, OPcache removes all comments from the PHP source code during the optimization process. This removal of comments helps to reduce the memory footprint of the cached bytecode, resulting in improved performance.

However, there are cases where preserving comments in the cached bytecode can be beneficial. For example, if your PHP scripts contain annotations or documentation within comments, enabling opcache.save_comments allows you to retain this information in the cached bytecode.

Enabling opcache.save_comments

To enable the opcache.save_comments directive, you need to set it to “1” in your php.ini file. Here’s an example:

opcache.save_comments=1

Once enabled, OPcache will preserve comments in the cached bytecode, allowing you to access them during runtime. This can be particularly useful for debugging purposes or when using tools that rely on comments for code analysis.

Considerations and Best Practices

While enabling opcache.save_comments can be beneficial in certain scenarios, it’s important to consider the following best practices:

  • Balance between performance and memory usage: Preserving comments in the cached bytecode increases the memory footprint of OPcache. If memory usage is a concern, it’s recommended to disable opcache.save_comments.
  • Codebase compatibility: Enabling opcache.save_comments assumes that your PHP scripts rely on comments for specific purposes. Ensure that your codebase is compatible with this configuration before enabling it.
  • Regularly review and optimize: As with any PHP configuration, it’s essential to regularly review and optimize your settings based on the specific requirements of your applications. Monitor the performance impact of enabling opcache.save_comments and adjust accordingly.

Summary

The opcache.save_comments directive in the php.ini file allows you to control whether comments are preserved in the cached bytecode by the PHP OPcache extension. Enabling opcache.save_comments can be beneficial when your PHP scripts rely on comments for annotations or documentation. However, it’s important to balance the performance impact and memory usage when considering this configuration. To learn more about optimizing your PHP applications with VPS hosting, visit Server.HK.

Recent Posts

  • How to Configure Nginx Load Balancing on Hong Kong VPS for High-Traffic Sites (2026)
  • How to Migrate Your Website to a Hong Kong VPS: Zero-Downtime Transfer Guide (2026)
  • How to Set Up Redis on Hong Kong VPS: Caching, Queues, and Session Storage (2026)
  • How to Host a Python Flask or Django Application on Hong Kong VPS (2026)
  • How to Set Up WireGuard VPN on a Hong Kong VPS: Step-by-Step Guide 2026

Recent Comments

  1. vibramycin injection on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  2. allopurinol for gout on CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  3. antibiotics online purchase on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)
  4. linezolid cost oral on Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  5. metoprolol generic on Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot