Welcome to Centmin Mod Community
Register Now

Mautic dynamic JS not being cached

Discussion in 'Other Web Apps usage' started by Shirkit, Jul 24, 2022.

  1. Shirkit

    Shirkit New Member

    Feb 6, 2019
    Local Time:
    3:54 AM

    First I'd like to thank you for this maintaining CentminMod for so long.

    I have been using Centmin with Mautic for a while now without major issues, but I've never noticed that one of the JS files it creates does not get cached.

    The URL in question is this: https://mautic.huternutrition.com/form/generate.js?id=1

    I get the following response header

    HTTP/2 200 OK
    content-type: text/javascript; charset=UTF-8
    cache-control: max-age=0, must-revalidate, private
    date: Sun, 24 Jul 2022 01:55:29 GMT
    expires: Sun, 24 Jul 2022 01:55:29 GMT
    server: nginx centminmod
    x-powered-by: centminmod
    x-xss-protection: 1; mode=block
    x-content-type-options: nosniff
    access-control-allow-origin: *
    X-Firefox-Spdy: h2
    I'm trying to improve this response. Maybe I need something other than Expires+Cache-Control header to cache this file? Because this is generated by PHP.

    location ~ (.*)(mtc|generate).js {
        expires 7d;
        add_header Cache-Control "public, no-transform";
        try_files $uri /index.php?$args;
    This is not working and I guess because this gets redirected to a PHP file, which tells to not cache at any occasion. Which makes total sense, except for this case. Do you have any suggestion on how to cache this file? It's not even gziped.

    Any suggestions on how to improve this? Thank you!
  2. eva2000

    eva2000 Administrator Staff Member

    May 24, 2014
    Brisbane, Australia
    Local Time:
    4:54 PM
    Nginx 1.25.x
    MariaDB 10.x
    The response header you have for private and max-age=0 is preventing caching so you need to figure out where that response header is being set in your web app as it certainly isn't a Centmin Mod set cache control header by default.
    Code (Text):
    cache-control: max-age=0, must-revalidate, private