How we generate .htaccess file in frontity Code?

Hello Friends,

How we generate .htaccess file in frontity Code ?

Please help me for this?

Thanks

You can’t and shouldn’t be needed. It’s an Apache file (although sort-of supported in Nginx) and has nothing to do with NodeJS or Frontity.

So unless you’re creating a server environment with Apache/Nginx and NodeJS, or use embedded mode with WordPress (which already has an .htaccess file), you don’t need to worry about it.

Hi @Johan

Thanks For reply me.

I need some pagespeed code in .htaccess file for frontity site. so how we will manage code for this.

Thanks

If you run your Frontity server through an Apache proxy it will work, otherwise an .htaccess file will be useless.

If you run it through Nginx you need to find a guide on how to set cache times there.

When you just use npx frontity serve you’re out of luck and you should look at using a CDN or Cloudflare.

Hi @bhagvan.vrinsofts

As @Johan has already observed, .htaccess is the configuration file for Apache. Frontity does not use Apache and so .htaccess doesn’t apply to the configuration for a Frontity-based website.

Frontity uses the Koa framework. You could check out the koa-cache-control for configuring your caching policy.

Hi @mburridge

Any reference how we implement " koa-cache-control " in frontity site?

Thanks

As I said before, it’s easier to setup a reverse proxy with Nginx than trying to modify the core of Frontity.

Check out How To Set Up a Node.js Application for Production on Debian 10 | DigitalOcean or this Gist Set up nginx as a reverse proxy to node.js. · GitHub

Please note; this topic requires some knowledge about server administration, while there are simpler solutions like CDN’s (Cloudflare is easy to set and works like a charm) which will do exactly the same just without all the tech-stuff.

2 Likes