WordPress best performance .htaccess file content

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript


#BEGIN EXPIRES HEADERS
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default expiration: 1 hour after request
ExpiresDefault "now plus 1 hour"
# CSS and JS expiration: 1 week after request
ExpiresByType text/css "now plus 1 week"
ExpiresByType application/javascript "now plus 1 week"
ExpiresByType application/x-javascript "now plus 1 week"
# Image files expiration: 1 month after request
ExpiresByType image/bmp "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/jp2 "now plus 1 month"
ExpiresByType image/pipeg "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/svg+xml "now plus 1 month"
ExpiresByType image/tiff "now plus 1 month"
ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/ico "now plus 1 month"
ExpiresByType image/icon "now plus 1 month"
ExpiresByType text/ico "now plus 1 month"
ExpiresByType application/ico "now plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</IfModule>
#END EXPIRES HEADERS

# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
 <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
 Header set Cache-Control "max-age=2592000, public"
 </filesMatch>
 <filesMatch "\.(css)$">
 Header set Cache-Control "max-age=604800, public"
 </filesMatch>
 <filesMatch "\.(js)$">
 Header set Cache-Control "max-age=216000, private"
 </filesMatch>
 <filesMatch "\.(x?html?|php)$">
 Header set Cache-Control "max-age=600, private, must-revalidate"
 </filesMatch>
</ifModule>
# END Cache-Control Headers


# ENABLE LITESPEED CACHE START
<IfModule LiteSpeed>
CacheEnable public
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{HTTP_HOST} ^sample.com|sample.net|sample.org [NC]
RewriteCond %{REQUEST_URI} !login|admin|register|post|cron
RewriteCond %{QUERY_STRING} !nocache
RewriteRule .* - [E=Cache-Control:max-age=300]
</IfModule>
# ENABLE LITESPEED CACHE END

# START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
# END ENABLE KEEP ALIVE


<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Step by step overview guide for setup business WhatsApp API

Step by step overview guide for setup business WhatsApp API with Facebook business account

What is the criteria to check my business Facebook is active for WhatsApp api

after that your WhatsApp api is fully activated.

  1. Must have Facebook business account setting
    a. WhatsApp account added into Facebook business setting
    b. Add system user
    c. Assign an App to system user via add assets
    d. Generate token for final use of WhatsApp api with selected permission
  2. Create app and add it into business Facebook account
    Note : for use WhatsApp api app type must be business

*Step by step overview guide for setup business WhatsApp API
*What is business WhatsApp API
*How to implement WhatsApp API

#1101 error in mysql / phpmyadmin

1101 – BLOB, TEXT, GEOMETRY or JSON column ‘answer’ can’t have a default value

Probably your development environment allows the defaults and the production environment doesn’t. You can either upgrade your production system or not use that feature.

How to disable strict mode in MySQL 5 (Windows):

  • Edit /my.ini and look for linesql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  • Replace it withsql_mode='MYSQL40'
  • Restart the MySQL service (assuming that it is mysql5)net stop mysql5 net start mysql5

If you have root/admin access you might be able to execute

mysql_query("SET @@global.sql_mode='MYSQL40'");

#2006 – MySQL server has gone away

MySQL/MariaDB related:

  • wait_timeout – Time in seconds that the server waits for a connection to become active before closing it.
  • interactive_timeout – Time in seconds that the server waits for an interactive connection.
  • max_allowed_packet – Maximum size in bytes of a packet or a generated/intermediate string. Set as large as the largest BLOB, in multiples of 1024.

Example of my.cnf:

[mysqld]
# 8 hours
wait_timeout = 28800
# 8 hours
interactive_timeout = 28800
max_allowed_packet = 256M

If you are using xampp server :

Go to xampp -> mysql -> bin -> my.ini

Change below parameter :

max_allowed_packet = 500M

innodb_log_file_size = 128M

send file using volley android

This is what I used to upload a PDF, but you can use it to any file. I used the same VolleyMultipartRequest, you just have to get the data from the file to upload it. Hope it helps you!

private void uploadPDF() {
    VolleyMultipartRequest volleyMultipartRequest = new VolleyMultipartRequest(
            Request.Method.POST,
            url,
            new Response.Listener<NetworkResponse>() {
                @Override
                public void onResponse(NetworkResponse response) {
                    //Handle response
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    //Handle error
                }
            }
    ) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            //Params
            return params;
        }

        @Override
        protected Map<String, DataPart> getByteData() {
            Map<String, DataPart> params = new HashMap<>();
            String pdfName = String.valueOf(System.currentTimeMillis() + ".pdf");
            params.put("pdf", new DataPart(pdfName, getFileData()));
            return params;
        }
    };

    //I used this because it was sending the file twice to the server
    volleyMultipartRequest.setRetryPolicy(
            new DefaultRetryPolicy(
                    0,
                    -1,
                    DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
            )
    );

    requestQueue.add(volleyMultipartRequest);
}

private byte[] getFileData() {
    int size = (int) pdf.length();
    byte[] bytes = new byte[size];
    byte[] tmpBuff = new byte[size];

    try (FileInputStream inputStream = new FileInputStream(pdf)) {
        int read = inputStream.read(bytes, 0, size);
        if (read < size) {
            int remain = size - read;
            while (remain > 0) {
                read = inputStream.read(tmpBuff, 0, remain);
                System.arraycopy(tmpBuff, 0, bytes, size - remain, read);
                remain -= read;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return bytes;
}

5 Reasons to Invest with Paytm Money

I don’t need to Invest.

You do. Have goals? Like smart people, invest to achieve them faster.

I don’t have enough money to Invest.

You just need as little as Rs.100 to start with.

I don’t want to take a big risk.

Get a free risk assessment done on Paytm Money – Invest accordingly.

I don’t know which funds to pick.

Easy. Our experts have picked mutual funds exclusively for you in the form of investment packs.

I don’t have the financial expertise to manage

Mutual Funds are managed by financial experts, hence, you do not need to be an expert.

change app type Facebook

App types cannot be changed. If your app needs products, permissions, or features that are unavailable to its current type you must create a new app with a different type instead.

how activate WhatsApp business messaging permission in Facebook developer

Register your App

We recommend this setup to be done by someone with an admin role in the Business Manager containing your WhatsApp Business Accounts. This avoids permission errors.

  1. Register a Facebook app on the Facebook Developers website using your personal profile (don’t worry, the app will belong to the Business Manager in the end). Your app type needs to be Business or None to use the WhatsApp Business Management API. Find more information on App Types in the App Development documentation.
  2. Find your app ID. Go to developers.facebook.com/apps, locate the app you have registered, and click on the app. A new screen opens up. Copy the App ID displayed on top of the page:
  3. Now go to https://developers.facebook.com/apps/{app-id}/settings/advanced to import the app into your Business Manager —replace {app-id} with the ID you got in Step 2. The Business Manager you use should contain your WhatsApp Business Accounts.
  4. Check for additional instructions in the app configuration, especially those related to GDPR that might apply to your specific case.

For more information about registering as a developer, creating your app, app roles, app modes, please see the App Development documentation.

App Review

When you initially register your app it will be set to Development mode. Apps in Development mode are automatically approved for all login permissions, features, and product-specific features for testing purposes. However, these permissions are limited —the app can only use those permissions to access data of users with roles in your app, like admins and developers.

In order to switch your Facebook app from Development mode to Live mode, it must go through App Review. If you want higher rate limits or would like to access a WhatsApp Business Account not in your Business Manager, you need to go through App Review.

Implementing the API

To make API calls to this API’s endpoints, you will need to do the following:

  1. Acquire an access token through a System User or Facebook Login.
  2. Be able to make API calls using the tool of your choice.

We recommend reading Using the Graph API to understand the API’s base concepts. After doing so, you will be more effective when consulting the WhatsApp Business Management API Reference to perform actions.

1. Acquire an Access Token Using a System User or Facebook Login

1.1 Deciding how to set up your system

Both Graph API and Marketing API calls require an access token to be passed as a parameter in each API call. This token can be acquired multiple ways, the following being the most common:

  1. Create a System User in your Business Manager and acquire a non-expiring token to be used for backend system integrations. This works for cases such as “a system from company X generates a weekly report on message volume from a certain WhatsApp Business Account without human intervention”.
  2. Use Facebook Login to acquire a user access token and request specific permissions. This is recommended when actions will be performed on behalf of a user, for example, “user X creates a new message template using a tool built by company Y”.

For More …

how enable whatsapp_business_messaging permission

At current time, these APIs are available only to selected Meta partners, if you are one of their Partners you can request those permissions from the key account manager, you are communicating with.

WhatsApp Business App

WhatsApp Business is free to download and was built with the small business owner in mind. The app makes it easy to personally connect with your customers, highlight your products and services, and answer their questions throughout their shopping experience. Create a catalog to showcase your products and services and use special tools to automate, sort and quickly respond to messages.

WhatsApp can also help medium and large businesses provide customer support and deliver important notifications to customers.

how to check app is installed or not in android using JavaScript | Check if android app is installed from web page browser

To avoid this or to avoid connect your app to some url you can do another trick to implement this using PHP and JS.

  1. You must create an intent-filter on your app’s main activity like this:
<intent-filter android:label="filter_react_native">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="MyCustomScheme" android:host="MyCustomHost" />
</intent-filter>
  1. Create PHP file redirect_to_app.php which will work in case user have the app installed.
<?php
header('Location: MyCustomScheme://MyCustomHost');
  1. Create HTML/PHP file check_redirect_to_app.php which must be shown for users which didn’t install your app yet.
...
<a href="https://play.google.com/store/apps/details?id=YOUR_APP_PACKAGE_NAME">Please install the application</a>
...

<script>
    location.href = '...redirect_to_app.php';
</script>
  1. Redirect users to check_redirect_to_app.phpcheck_redirect_to_app.php will try to redirect to MyCustomScheme://MyCustomHost automatically. In case it will not find such a app, it will coninue to show check_redirect_to_app.php content.