Comment to 'SOLVED:Browser caching is not working properly with nginx or apache'
  • By default files which are in UNA storage are already send proper headers to be cached by browser, default setting is 30 days, you can change it in sys_objects_storage table cache_control field, however it's for public files only. Private files are cached for short period of time, the same as token_life, by default 6 minutes.

    Also I believe that more correct setting for Nginx to cache static files would be (if UNA is installed in the domain ROOT folder):

        location ~* ^(/cache_public/|/plugins_public/|/modules/|/studio/|/template/).+\.(jpg|jpeg|gif|css|png|js|ico|svg|eot|ttf|woff|woff2|)$ {
            expires 1M;
            access_log off;
            add_header Cache-Control "public";
            try_files       $uri =404;
        }
    
    

    Hi,

    When I used this caching block for nginx, it stopped loading some pictures on the una installation, such as the default user icon (/modules/boonex/persons/template/images/no-picture-thumb.png) - returns 404.

    Is there something I'm missing?

    💓0 😆0 😲0 😥0 😠0 0
    • Understood, but my UNA is installed in the root folder. Something wrong with caching?

      I would suggest to check Nginx access and error logs to find the reason of the problem.

      There was no error posted, just a 404 in the access log.

      If I just change

      try_files \$uri =404;

      to

      try_files $uri =404;

      It works fine after that.

      Is that ok?

      💓0 😆0 😲0 😥0 😠0 0
      • Understood, but my UNA is installed in the root folder. Something wrong with caching?

        I would suggest to check Nginx access and error logs to find the reason of the problem.

        There was no error posted, just a 404 in the access log.

        If I just change

        try_files \$uri =404;

        to

        try_files $uri =404;

        It works fine after that.

        Is that ok?

        I just realized that within this thread, you don't mention putting a "\" in front of "$uri".

        However, I copied over the code from here, initially, and it is there - that was what was causing the issue.

        https://una.io/page/view-discussion?id=760

        All solved now, thanks.

        💓0 😆0 😲0 😥0 😠0 0
        • I just realized that within this thread, you don't mention putting a "\" in front of "$uri".

          However, I copied over the code from here, initially, and it is there - that was what was causing the issue.

          https://una.io/page/view-discussion?id=760

          Thank you, I've corrected the code there.

          💓0 😆0 😲0 😥0 😠0 0

        UNA - Network Infrastructure for Communities

        Close