1

I'm running a LAMP server on Ubuntu 16.04, typical LAMP setup. We have a family of websites running all controlled through virtual host files in the sites-available folder.

Pretty aggressive caching for the websites is handled through the global apache.conf file, and there is an opcache solution for php.

One website is experiencing some issues, but caching is preventing me from diagnosing it properly.

Preferably within the website.conf file, is it possible to configure Apache to ignore caching for only this website? I'd like to serve every request, and I'd like for PHP to be rebuilt from scratch on every request, too, (rather than be served from the opcode cache should there be a hit, and preferably without having to add a function like opcache_reset() to the top of every php page, or turn it off in the php.ini file).

2

It is possible to configure apache to ignore caching in these various contexts:

  1. server config - used in httpd.conf,
  2. virtual host,
  3. directory - used inside Directory, Location, Files, If, and Proxy containers in the server configuration files,
  4. .htaccess

In your case its option 2 in this format CacheDisable url-string | on:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    CacheDisable on    # OR
    CacheDisable "/foo_files"  # OR
    <Location "/foo">
        CacheDisable on
    </Location>
</VirtualHost>

Source:

https://httpd.apache.org/docs/2.4/mod/mod_cache.html#cachedisable

http://www.serverlab.ca/tutorials/linux/web-servers-linux/improve-website-performance-by-enabling-caching-in-apache/

https://www.digitalocean.com/community/tutorials/how-to-configure-apache-content-caching-on-ubuntu-14-04

  • Where do I put this Virtual Host file? – Aaron Franke Jan 6 at 18:16
  • Put it in /etc/apache2/sites-available then run sudo a2ensite <name_of_conf_file>! – George Udosen Jan 6 at 18:20
  • I put it in 000_default.conf and this happens: apachectl[27596]: AH00526: Syntax error on line 30 of /etc/apache2/sites-enabled/000-default.conf: Invalid command 'CacheDisable', perhaps misspelled or defined by a module not included in the server configuration – Aaron Franke Jan 6 at 18:30
  • Put it in it's own file! – George Udosen Jan 6 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.