• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Dukemaster

Regular Pleskian
Hi @ all
today I made the further configuration of ngx_pagespeed which is running successfully since a few weeks.
Today changed the configured to with Redis for Shared Memory Metadata Cache.
The directory /var/cache/pagespeed/ was successful created after applying
Code:
pagespeed CreateSharedMemoryMetadataCache "/var/cache/pagespeed/" 51200;
in /etc/nginx/nginx.conf. But it is empty. (owner is root, that is a little suspect for me but could be okay, because redis is installed by root, only pagespeed related directories have nginx as owner).
And I don't know to which domain I have to change the following configuration part relating to the part above and where to place it. (additional nginx, or nginx.conf, vhost.conf) and "What do they mean with "alt".example.com
Code:
server {
      listen 80;
      server_name www.example.com;
      pagespeed FileCachePath "/var/cache/pagespeed/";
    }
    server {
      listen 80;
      server_name alt.example.com;
      pagespeed FileCachePath "/var/cache/pagespeed/";
    }

In the pagespeed console I saw the following error for each domain under "Show metadatacache" (+URL):
Code:
Metadata cache key:rname/aj_b_kw9djfggl1RU1OJhvl/https://www.domain.com/@@_
cache_ok:false
can_revalidate:false
partitions:

and in the message history every few minutes the following red errors:
Code:
Failed to make directory /var/cache/pagespeed/shm_metadata_cache: Permission denied
[Sat, 16 Sep 2017 22:00:21 GMT] [Error] [19097] Could not create directories for file /var/cache/pagespeed/shm_metadata_cache/snapshot/,2Fvar/cache/pagespeed/,2Fmetadata_cache/1/64/4452/128/119,.temp
[Sat, 16 Sep 2017 22:00:21 GMT] [Error] [19097] [/var/cache/pagespeed/shm_metadata_cache/snapshot/,2Fvar/cache/pagespeed/,2Fmetadata_cache/1/64/4452/128/119,.templV51yC:0] opening temp file: No such file or directory
[

This means a kind of /temp/ directory could not be created because of permissions.

Would be fine if somebody could help me solving these problems, mainly the last error message.
I think they belong all to the same configuration problem.
Perhaps master @UFHH01 could help, because I followed his great tutorial installing and compiling nginx with ngx_pagespeed and brotli.

Lots of greets and a happy weekend.
 
Last edited:
Hi Dukemaster,

"What do they mean with "alt".example.com
"alt." is here a synonym for ALTERNATIVE subdomain.

... but ( !!! ), pls. consider to use the serverwide nginx - configuration file "nginx.conf" and define your settings inside the "http" - section instead and leave out the "server" - section examples completely, as Plesk takes care of it for all your (sub)domains.

Recommended example ( at "nginx.conf" - INSIDE the "http" - section ):
Code:
    http {
.....
.....

        proxy_buffer_size   128k;
        proxy_buffers   4 256k;
        proxy_busy_buffers_size   256k;
.....
.....
        pagespeed on;
        pagespeed LowercaseHtmlNames on;
        pagespeed XHeaderValue "Powered by ngx_pagespeed and Plesk";
        pagespeed StaticAssetPrefix /static/;
        pagespeed FileCachePath /var/ngx_pagespeed_cache;
        pagespeed PreserveUrlRelativity on;
        pagespeed EnableFilters combine_css,rewrite_css,move_css_above_scripts,combine_javascript,rewrite_javascript;
        pagespeed EnableFilters lazyload_images,inline_preview_images,resize_mobile_images,inline_google_font_css,rewrite_style_attributes;
        pagespeed EnableFilters prioritize_critical_css,make_google_analytics_async,outline_css,outline_javascript,move_css_to_head;
        pagespeed EnableFilters include_js_source_maps,canonicalize_javascript_libraries,local_storage_cache,convert_to_webp_lossless,insert_image_dimensions;
        pagespeed EnableFilters elide_attributes,extend_cache_pdfs,sprite_images,trim_urls,pedantic;
        pagespeed EnableFilters remove_quotes,dedup_inlined_images,insert_dns_prefetch,remove_comments,collapse_whitespace;
        pagespeed EnableFilters in_place_optimize_for_browser;
.....
.....
        include /etc/nginx/conf.d/*.conf;
    }


Failed to make directory /var/cache/pagespeed/shm_metadata_cache: Permission denied
To avoid permissions issues, you might consider to create the cache folder at "/var/*", as the cache folder and it's related subfolders need the permissions
Code:
nginx:nginx
In addition, pls. consider to run nginx as user "nginx" at your "nginx.conf". ;)

Example ( at "nginx.conf" ):
Code:
    user  nginx;
.....
.....
 
Last edited by a moderator:
In addition, pls. consider to run nginx as user "nginx" at your "nginx.conf"
Thanks so much for this amazing help @UFHH01 !!!
To your recommendations/advices: My nginx was already running as user nginx.
To help others people perhaps by my mistakes or not, I show now my whole config like it is before I make other changes recommended by You. It's like before I write this thread.

Code:
#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;
   
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;

    open_file_cache max=2000 inactive=20s;
    open_file_cache_valid 60s;
    open_file_cache_min_uses 5;
    open_file_cache_errors off;

    pagespeed on;
    pagespeed RedisServer "localhost:6379";
    pagespeed LRUCacheKbPerProcess     8192;
    pagespeed LRUCacheByteLimit        16384;
    pagespeed CreateSharedMemoryMetadataCache "/var/cache/pagespeed/" 51200;

    # Needs to exist and be writable by nginx.  Use tmpfs for best performance.
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    pagespeed EnableFilters combine_css,combine_javascript;
    pagespeed EnableFilters make_show_ads_async;
    pagespeed EnableFilters make_google_analytics_async;
    pagespeed EnableFilters extend_cache;
    pagespeed EnableFilters extend_cache_pdfs;
    pagespeed EnableFilters responsive_images,resize_images;
    pagespeed EnableFilters responsive_images_zoom;

    pagespeed StatisticsPath /ngx_pagespeed_statistics;
    pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
    pagespeed MessagesPath /ngx_pagespeed_message;
    pagespeed ConsolePath /pagespeed_console;
    pagespeed AdminPath /pagespeed_admin;
    pagespeed GlobalAdminPath /pagespeed_global_admin;
    pagespeed UsePerVhostStatistics on;
    pagespeed MessageBufferSize 100000;
    pagespeed EnableCachePurge on;

    pagespeed Statistics on;
    pagespeed StatisticsLogging on;
    pagespeed LogDir /var/log/pagespeed;
    pagespeed AdminPath /pagespeed_admin;

    pagespeed FileCachePath              "/var/cache/pagespeed/";
    pagespeed FileCacheSizeKb            102400;
    pagespeed FileCacheCleanIntervalMs   3600000;
    pagespeed FileCacheInodeLimit        500000;
 
    # BEGIN Google brotli - definitions, tuned by UFHH01
    brotli on;
    brotli_static on;
    brotli_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml image/gif image/jpeg application/atom+xml application/javascript image/png image/tiff image/x-ms-bmp application/font-woff application/json application/msword application/pdf application/postscript application/rtf application/vnd.apple.mpegurl application/vnd.ms-excel application/vnd.ms-fontobject application/vnd.ms-powerpoint application/vnd.wap.wmlc application/vnd.google-earth.kml+xml application/vnd.google-earth.kmz application/x-7z-compressed application/x-cocoa application/x-java-archive-diff application/x-perl application/x-rar-compressed application/x-shockwave-flash application/x-tcl application/x-x509-ca-cert application/xhtml+xml application/xspf+xml application/zip application/octet-stream audio/midi audio/mpeg audio/ogg audio/x-m4a audio/x-realaudio video/3gpp video/mp2t video/mp4 video/mpeg video/quicktime video/webm video/x-flv video/x-m4v video/x-mng video/x-ms-asf video/x-ms-wmv video/x-msvideo;
    brotli_comp_level 8;
    # END Google brotli - definitions, tuned by UFHH01

    # BEGIN gzip - Definitions, tuned by UFHH01
    gzip_static on;
    gzip on;
    gzip_proxied any;
    gzip_http_version 1.1;
    gzip_min_length 100;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml image/gif image/jpeg application/atom+xml application/javascript image/png image/tiff image/x-ms-bmp application/font-woff application/json application/msword application/pdf application/postscript application/rtf application/vnd.apple.mpegurl application/vnd.ms-excel application/vnd.ms-fontobject application/vnd.ms-powerpoint application/vnd.wap.wmlc application/vnd.google-earth.kml+xml application/vnd.google-earth.kmz application/x-7z-compressed application/x-cocoa application/x-java-archive-diff application/x-perl application/x-rar-compressed application/x-shockwave-flash application/x-tcl application/x-x509-ca-cert application/xhtml+xml application/xspf+xml application/zip application/octet-stream audio/midi audio/mpeg audio/ogg audio/x-m4a audio/x-realaudio video/3gpp video/mp2t video/mp4 video/mpeg video/quicktime video/webm video/x-flv video/x-m4v video/x-mng video/x-ms-asf video/x-ms-wmv video/x-msvideo;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    # END gzip - Definitions, tuned by UFHH01

    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;


Greets
 
I will directly show you what happened after following your advices-
In the same moment I changed owner of /var/cache/pagespeed to both nginx and permissions 755 (like the usual directory /var/ngx_pagespeed_cache) it was filled by same new created directories and datas (same like in ngx_pagespeed_cache).
Lol thanks @UFHH01 thats what I did. we wrote the post at the same time...lol :p --> :rolleyes:
 
Last edited:
A question @UFHH01 which doesn't belong to the topic itself, only by interest. I added also adsense to my handler-list. Don't you use adsense, or has it a special reason leaving it out in your handler list?
Code:
pagespeed EnableFilters make_show_ads_async;
For this not important side-question I won't open a special topic, my friend. Happy you helped me with the main things. Yes, I will leave this server definition out like you recommended.
Lots of greets
 
Last edited:
Everything seems running very very fine:Except warning (no error, I know) with timestamp of cleantime. It comes every (common) 5 minutes which is the normal pagespeed sequence for different cronjobs.
[Sun, 17 Sep 2017 09:04:01 GMT] [Warning] [2140] Failed to read cache clean timestamp /var/cache/pagespeed/!clean!time!. Doing an extra cache clean to be safe.

[Sun, 17 Sep 2017 09:04:01 GMT] [Info] [2140] Need to check cache size against target 104857600

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] Trying to serve rewritten resource in-place: https://217.160.92.49/

[Sun, 17 Sep 2017 09:04:40 GMT] [Error] [2140] [/var/log/pagespeed/stats_log_dummy_hostname:-925:0] opening output file: Permission denied

[Sun, 17 Sep 2017 09:04:40 GMT] [Error] [2140] Error opening statistics log file /var/log/pagespeed/stats_log_dummy_hostname:-925.

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] Could not rewrite resource in-place because URL is not in cache: https://217.160.92.49/

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] Cache entry is expired: https://217.160.92.49/img/logo.png (fragment=217.160.92.49)

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] Cache entry is expired: https://217.160.92.49/css/style.css (fragment=217.160.92.49)

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] Cache entry is expired: https://217.160.92.49/favicon.ico (fragment=217.160.92.49)

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] HTTPCache key=https://217.160.92.49/img/logo.png fragment=217.160.92.49: remembering recent failure for 299 seconds.

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] HTTPCache key=https://217.160.92.49/img/logo.png fragment=217.160.92.49: remembering recent failure for 299 seconds.

[Sun, 17 Sep 2017 09:04:40 GMT] [Warning] [2140] Failed to read cache clean timestamp /var/cache/pagespeed/!clean!time!. Doing an extra cache clean to be safe.

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [2140] Need to check cache size against target 104857600

[Sun, 17 Sep 2017 09:04:40 GMT] [Warning] [2140] Failed to read cache clean timestamp /var/cache/pagespeed/!clean!time!. Doing an extra cache clean to be safe.

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [2140] Need to check cache size against target 104857600

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] HTTPCache key=https://217.160.92.49/css/style.css fragment=217.160.92.49: remembering recent failure for 299 seconds.

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [12493] HTTPCache key=https://217.160.92.49/css/style.css fragment=217.160.92.49: remembering recent failure for 299 seconds.

[Sun, 17 Sep 2017 09:04:40 GMT] [Warning] [2140] Failed to read cache clean timestamp /var/cache/pagespeed/!clean!time!. Doing an extra cache clean to be safe.

[Sun, 17 Sep 2017 09:04:40 GMT] [Info] [2140] Need to check cache size against target 104857600
 
Don't you use adsense
You may add as much as YOU desire, Dukemaster... it's YOUR server and not one of mine! :p
( I DO use AdSense as well and many, many more additional settings, but the goal is not to copy MY configurations, it is helping YOU to sort out YOUR issues/errors/problems. :) )
 
Yes, @UFHH01 I know this for sure. It would possible result in less performance in my configuration environment. I studied your config and came to same conclusion. But I have to mention by the first view, that it is very special and made especially for your sites and needs. But it will be a wonderful inspiration for my needs.
Danke Uwe, echt. Du bist klasse.
 
Last edited:
Hi @UFHH01
Yesterday I didn't realize what you mean, I thought you mean the permissions. Sorry to misunderstand.
Please, can you push me on the right way.
What do meant with this.
Which one I shall change? I'm a little overwhelmed by pagespeed in the moment.
Also for using /var/ngx_pagespeed_cache as an tmpfs
Code:
Last night I made a experiment and mount /var/ngx_pagespeed_cache/ as tmpfs.
If this work together, I don't really know.
[CODE]root@server:~# df | grep tmpfs
tmpfs                   1639864    20580   1619284   2% /run
tmpfs                   8199312        0   8199312   0% /dev/shm
tmpfs                      5120       20      5100   1% /run/lock
tmpfs                   8199312        0   8199312   0% /sys/fs/cgroup
tmpfs                   1073152     3180   1069972   1% /var/ngx_pagespeed_cache
tmpfs                   1639864        0   1639864   0% /run/user/0


Would be great if you can show me the right direction, please.

I made this change today:
pagespeed on;
pagespeed RedisServer "localhost:6379";
pagespeed LRUCacheKbPerProcess 8192;
pagespeed LRUCacheByteLimit 16384;
pagespeed CreateSharedMemoryMetadataCache "/var/ngx_pagespeed_cache/" 51200;
pagespeed DefaultSharedMemoryCacheKB 5000
***** added the default shared memory cache config *****

pagespeed FileCachePath "/var/cache/pagespeed/";
pagespeed FileCacheSizeKb 102400;
pagespeed FileCacheCleanIntervalMs 3600000;

Now it works in realtime except the filecache. headers fetching is okay.
Greets
 
Last edited:
Hi Dukemaster,

you published at: => #4

Code:
...
    pagespeed on;
    pagespeed RedisServer "localhost:6379";
    pagespeed LRUCacheKbPerProcess     8192;
    pagespeed LRUCacheByteLimit        16384;
    pagespeed CreateSharedMemoryMetadataCache "/var/cache/pagespeed/" 51200;

    # Needs to exist and be writable by nginx.  Use tmpfs for best performance.
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    pagespeed EnableFilters combine_css,combine_javascript;
    pagespeed EnableFilters make_show_ads_async;
    pagespeed EnableFilters make_google_analytics_async;
    pagespeed EnableFilters extend_cache;
    pagespeed EnableFilters extend_cache_pdfs;
    pagespeed EnableFilters responsive_images,resize_images;
    pagespeed EnableFilters responsive_images_zoom;

    pagespeed StatisticsPath /ngx_pagespeed_statistics;
    pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
    pagespeed MessagesPath /ngx_pagespeed_message;
    pagespeed ConsolePath /pagespeed_console;
    pagespeed AdminPath /pagespeed_admin;
    pagespeed GlobalAdminPath /pagespeed_global_admin;
    pagespeed UsePerVhostStatistics on;
    pagespeed MessageBufferSize 100000;
    pagespeed EnableCachePurge on;

    pagespeed Statistics on;
    pagespeed StatisticsLogging on;
    pagespeed LogDir /var/log/pagespeed;
    pagespeed AdminPath /pagespeed_admin;

    pagespeed FileCachePath              "/var/cache/pagespeed/";
    pagespeed FileCacheSizeKb            102400;
    pagespeed FileCacheCleanIntervalMs   3600000;
    pagespeed FileCacheInodeLimit        500000;
...
... where you configured TWICE :
Code:
pagespeed FileCachePath /var/ngx_pagespeed_cache;
and later:
Code:
pagespeed FileCachePath              "/var/cache/pagespeed/";
Therefore you got an ":rolleyes:" - smiley from me, as the second configuration overwrites the first one. ;)

I can't suggest something to "/var/ngx_pagespeed_cache/" mounted over "tmpfs", as I never used it.

I can't suggest something to "redis" - PageSpeed - settings, as I never used it.
 
I apologize for being so much attracted by working pagespeed that I read your boxes too fast to get the full content.
Redis with tmpfs seems working pretty good. It's tagged as experimental by AMP but from the first sight and run its ok.
Realtime monitoring works now, too. Today I made several tests.
I read the pagespeed docus again and came to the conclusion I need a closer look for image handlers. My sites are dominated by image delivering with high resolution and large sizes.
Some handler are similar to your presented ngx_pagespeed configuration, not everything is bad for my needs. Now I know the reason why my images were broken yesterday.
I'm disappointed about the fact that it's impossible to LoadFromFile with my community software which has no explicit static directory, and those which do so, have hundreds of sub-directories.
But it goes further.

Thanks for your extraordinary help here in Plesk forums @UFHH01
 
Last edited:
Back
Top