upgrading – update.php: Cache Expiration – hook status – No expirable cache enabled

@ www.example.com/update.php, I receive a warning which prevents me from proceeding to the next step of the update process:

Cache Expiration – hook status – No expirable cache enabled None of the
enabled modules implements hook_expire_cache(). This means that
expire.module will not be having any effect. You should enable a
module implements this hook, like the Varnish module.

I don’t know how to proceed from here. Google has not returned anything relevant.

Help appreciated.
Steve

cache – How to make an Android app “forget” that it installed on my phone before?

Some apps like Facebook, LinkedIn, Tinder, etc. seem to have a mechanism to remember which Android phone installed their app. So if a user is banned on these apps, the next time somebody creates an account on the same Android phone, that account is flagged or even banned automatically.

What is the way to make sure the app forgets that my Android phone was used previously with a banned account? I tried to clear cache and delete app data, then uninstall the re-install the app but it still remembers! I tried it on different IP addresses but the same issue is there.

Does the app have access to the IMEI of the phone!??

I am on Android v10.

https – Nginx: could not allocate new session in SSL session shared cache “SSL” while SSL handshaking

What to make of this error? I get it a few times a day, often in a clump. 14 of them yesterday, scattered throughout, but with a cluster of 9 within a few seconds of each other.

My first thought was that my cache wasn’t big enough, but at 50m I think that’s good enough for 200,000 sessions. I have a timeout of 24h and typically get 1,000,000 page views per month, so I don’t think that’s likely to be the issue.

Furthermore, if the cache WERE to run out of space, I’m pretty sure it would just silently purge the oldest entry and add the new one, with no message in the error log.

So what causes this error? I feel it can’t be a problem with the system being IO-bound – I have NVMe drives that are barely tickled by the level of traffic I have.

Any ideas?

Thank you

cache – Storing statistics for cached content

I have a database-driven website where the content only changes about once per day. The page consists of a list of businesses. Every time a page is viewed each business receives a “view.” Since the content does not change very often I would like to serve it from a cache to avoid lookups/speed up the request (e.g. Nginx or Varnish). What is the best practice for serving cached content while still capturing statistics every time the business listings are viewed?

I would like to avoid Javascript. The other option that comes to mind is the use of a static image with query parameters: clear.png?listings=1,2,3,4,5,6,7,8,9,10, but that feels sloppy. Is there a better way?

Design that hides cache as an implementation detail

So first as a small point – finalize is depreciated. Don’t use it. You need to rely on calling contexts to handle closing the object. Use try-with-resources where you can and maybe use reference counting to know when to de-allocate the underlying object.

Beyond that, what want sounds most like object pooling. You can take inspiration from libraries like Jedis where there is an interface that represents all the operations you can perform and an object pool you can ask to borrow something that implements that interface from. You then either have your operations interface implement closable or make some sub interface that does, and calling .close() on that returned object returns it to the pool.

In that example everything is using Apache Commons Pool which, while I have no experience using except as a consumer, seems to be in the right direction.

The same general technique is used by any sort of “resource pooling” object like HikariCP which pools database connections or java’s Executors which pool access to threads.

To make everything work properly across multiple threads, I do suggest using a library like Commons Pool, but we can show the general pattern without it.

First, segregate out the operations of Heavy

public interface Heavy extends Closeable {
    int add(int x, int y);
}

If you are on the newest Java this might be a good place to use sealed interfaces.

Next, make your actual implementation that handles the native resource.

final class HeavyNative implements Heavy {
    private final Pointer pointer;

    HeavyNative(String name) {
        this.pointer = ...???...;
    }
    
    @Override
    public int add(int x, int y) {
        // oogabooga
    }

    @Override
    public void close() {
        pointer.free();
    }
}

Depending on how you are structuring things, you might see some benefit in making the actual implementations here package-private, which is what I am doing.

Then you can make your object that lets you borrow a Heavy. I am going to hand-wave this a bit and use synchronized for everything, but do look into Apache Commons Pool and similar libraries. That being said, if you are reluctant to use dependencies at all, this will (probably) work.

public final class HeavyFactory {
    // You could also wrap this logic into HeavyNative or make an entirely separate class
    // or make it not atomic since that doesn't super matter in an entirely synchronized
    // context.
    private static record RefCountedHeavy(Heavy heavy, AtomicInteger rc);
    
    private Map<String, RefCountedHeavy> givenOut = new HashMap<>();
    
    public synchronized Heavy getHeavy(String name) {
        if (givenOut.contains(name)) {
            final var refCountedHeavy = givenOut.get(name);
            refCountedHeavy.rc().addAndGet(1);
            return new BorrowedHeavy(name, refCountedHeavy.heavy(), this);
        }
        else {
            final var heavy = new HeavyNative(name);
            this.givenOut.put(name, new RefCountedHeavy(heavy, new AtomicInteger(1)));
            return new BorrowedHeavy(name, heavy, this);
        }
    }
    
    synchronized void returnHeavy(BorrowedHeavy heavy) {
        final var refCountedHeavy = givenOut.get(heavy.name);
        final var rc = refCountedHeavy.rc().addAndGet(-1);
        if (rc == 0) {
            // no one is using it
            refCountedHeavy.heavy().close();
            givenOut.remove(heavy.name);
        }
    }

}

So you can get a Heavy from this, and if you know you have a Heavy that is borrowed you can return it. Then for BorrowedHeavy:

 // This could be a static class in the factory if you wanted
final class BorrowedHeavy implements Heavy {
    // Or whatever other book keeping you want accessible to handle returns
    // you can make whatever the "key" is part of the interface or do some other
    // method of book keeping if you want.
    final String name; 
    private final Heavy heavy;
    private final HeavyFactory maker;

    BorrowedHeavy(String name, Heavy heavy, HeavyFactory maker) {
        this.name = name;
        this.heavy = heavy;
        this.maker = maker;
    }

    // delegate all functionality
    @Override
    public int add(int x, int y) {
        return this.heavy.add(x, y);
    }

    // and when closed, return to the pool
    @Override
    public void close() {
        this.maker.returnHeavy(this);
    }
}

Then, when all is said and done, you just need to maintain a reference to a single HeavyFactory everywhere.

In fact, you could even make HeavyFactory package private and make a singleton instance on the Heavy interface.

public interface Heavy extends Closeable {
    private static HeavyFactory factory = new HeavyFactory();

    static Heavy forName(String name) {
        return factory.getHeavy(name);
    }
    
    int add(int x, int y);
}

At which point the public interface into your code is just that single method and you are free to fiddle about with the specifics of pooling however you want to.

try (final var heavy = Heavy.forName("abc")) {
    System.out.println(heavy.add(1, 2));
}

Does that make sense? I know the code got kinda messy with BorrowedHeavy and HeavyFactory so I can clean up or clarify if needed, but to summarize the general points:

  • What data structure to use? Probably hash map unless you want to include libraries at which point just use libraries made for object pooling.
  • How do you get wrapper objects to communicate back? Give them a reference to the factory when they are made and communicate at close() time.
  • Interfaces are your friends.

w3 total cache write a brokent url

I’m using w3 total cache, and I have a s3 bucket where I store all my files (wp-includes, wp-content/themes, wp-content/uploads), everything seems to work fine except for the themes directory
for examples, for the includes and uploads file the src or href attributes is written correctly, like:

<img src="https://bucketname.s3.amazonaws.com/wp- 
content/uploads/2020/10/imagename.png">

but for the css and js that comes from themes directory is written like this

<link rel='stylesheet' id='animate-css'  href='https://bucketname.s3.amazonaws.com/wp- 
content/themes/theme-name//css/animate.css.gzip?ver=1.0.0' type='text/css' media='all'/>

notice there is an additional “https://wordpress.stackexchange.com/” before ‘css’ as if there a directory without name,but when I open the file in new tab without the additional “https://wordpress.stackexchange.com/” it work and aws bucket return the file.
Any idea why w3 total cache is doing this?

javascript – DataURL Browser Cache Security Implications

What are the security implications that come with loading an image in dataURL format <img src="dataURL" />?

After signing into my website the browser loads an image in dataURL format for first time and take a few seconds to load. Later when I come back to the site and attempt to load the same image the image is loaded much faster. I’m assuming this is due to my browser caching the data URL. If this is true, how safe is that image stored in cache?

computer architecture – What does “associative” exactly mean in “n-way set-associative cache”?

I’m trying to grasp what does associative actually mean in n-way set-associative cache. I understand n-way set-associative cache as a concept; n is the degree of associativity, i.e., how many cache lines a set can hold.

If I take associative to mean “having the tendency to connect”, I get to the “sets tend to connect to…”, what, memory addresses?

But I’m not sure if this is the correct understanding.

Magento 2 – Missing enable / disable cache options in Admin

In Magento 2,I can’t enable/disable cache In System -> Cache Management, the two options are missing from the dropdown menu. what did wrong?

It’s in Default mode.

enter image description here

Anyone has idea on this?

optimization – Can WordPress plugins W3 Cache, Autoptimize, Stackpath CDN, and Shortpixel be used together?

I’m trying to combine some WordPress plugins to speed up my websites. Can I use

  • W3 Cache
  • Autoptimize
  • a CDN with Stackpath,
  • Shortpixel Image Optimization

together at the same time? Are there any settings within each plugin that need to be adapted so they work with each other?