Set of computers showing infrastructure for databases. Image by Suresh anchan from Pixabay.

Caching Mongoose queries in a native MongoDB collection

If you’re building a Node.js application with Mongoose, you’ve probably felt the pain of database performance at scale. The go-to solution? Add Redis. Set up a caching layer, wire it into your queries, and hope the invalidation logic doesn’t become a maintenance nightmare.

But what if we told you there’s a simpler way – one that uses the database you already have, requires zero additional infrastructure, and handles cache invalidation automatically?

Meet @sitelintpackages/mongoose-cache: a MongoDB-based caching solution for Mongoose queries with TTL and automatic invalidation support.

Continue reading “Caching Mongoose queries in a native MongoDB collection”
Virtual keyboard with virtual monitor that presents the code. Image by Gerd Altmann from Pixabay.

Fixing render-blocking fonts

Render-blocking fonts refer to fonts that prevent a web page from rendering or displaying its content until the font has been loaded. This can cause a delay in the page loading, resulting in a slower user experience.

When a web page is loaded, the browser reads the HTML and CSS files to determine the layout and styling of the page. If a font is specified in the CSS, the browser will typically wait for the font to be loaded before rendering the page. This is known as a render-blocking font because it blocks the rendering of the page until the font is available.

Render-blocking fonts can be a problem because they can cause a delay in the page loading, especially if the font is large or takes a long time to load.

To avoid render-blocking fonts, let’s explore techniques to fix the issue.

Continue reading “Fixing render-blocking fonts”
An old, open briefcase with a mini beach and sun in it

Optimizing background videos for fast loading. Tips and strategies for improved user experience

Adding videos to your website can sometimes be a double-edged sword. Web users love high-resolution videos, but if your website isn’t optimized to handle them, such content can cause performance problems.

When it comes to optimizing background videos for fast loading, there are several steps you can take, from choosing the right codec to implementing modern loading strategies.

Continue reading “Optimizing background videos for fast loading. Tips and strategies for improved user experience”
Hundreds of drawers symbolizing a large amount of occupied space

Flush (Delete or Empty) MongoDB log file

Sometimes the database might work slowly and one of the reasons is a large log file. Tracking database activity is crucial for performance and issues monitoring. However, the log file may grow and therefore may cause the performance issue because of more and more writing and reading on a larger and larger log file. We may avoid such problems by scheduling regular log rotation and keeping the log file size below a defined threshold. Let’s get started on figuring out how to address this issue.

Continue reading “Flush (Delete or Empty) MongoDB log file”